Best way to play Machine Gunner?

Hi everybody. I'm still relatively new to the game (LVL 35), and have been playing mostly AT, but have taken a liking to Machine Gunner from time to time. It seems obvious that the best way to play machine gunner on defense is find a safe defensive position and lay down a shit load of suppressive fire, but please advise me if I am off base on this.

What is the best way to play machine gunner on the attacking side? It seems to me the best way to do it is kind of play behind the front lines and lay down fire into the point were attacking, but it doesn't feel like I'm being the most effective this way. Can you guys give me some advice on the best strategies on being an effective machine gunner? TIA!