If your teamcomp doesn't have long-range poke or AoE, Heimer will give you a bad time. Poke lets you whittle him down despite his turrets, and also lets you take turrets out early game (late-game he just has more). AoE will either shred his turrets or force him to space them out, reducing the damage you take. You can also dodge their lasers to avoid a lot of pain. Never go in when the turret lasers are all charged.
If you're melee, your best bet is probably to just waveclear as well as you can and last-hit under turret - you won't be countering his pushing power. If your jungler ganks for you, try to take out at least one of his turrets first. If you're mobile but squishy, consider counterjungling or proxy farming instead of engaging him directly - you may have a better chance fleeing the enemy jungle than trying to jump directly on Heimer. Lane swaps can also help - someone on your team is probably better at dealing with him than you are.
Heimerdinger is at his most vulnerable when he pushes forward to set up a new line of turrets. Attack him before he can finish setting it up. Never facecheck unless you can see his turrets. Never attempt to fight his ult-turret, and make sure your team isn't lined up for its lasers to hit you all. Don't expect ganks to work if he's anywhere near his turrets with Zhonya's available.