If they're harassing, give it right back if you have a compitant support they will help with making them harass a scary thing. Other than that, let your support harass. I personally play an offensive support stance if I see them coming in to harass I get in their way to let my ADC farm.
In other lanes like Top lane it all depends on the match up really. If your nasus against gnar for example, they're gonna harass the shit outta you making CS damn near impossible.
Mid lane is one of the harder lanes IMO because you don't want to push while Casing because it leaves you open for tanks from all directions.
In a perfect world you don't want to farm to far out in the lane stay relatively close to turret but try not to let the minion wave push I to your turret, cause your gonna miss alot if CS to the turret.
As for the harassing, it's gonna happen there's nothing you can do about it unless like I said, harass them right back because they're missing CS as well.