Simply changing your reaction to such behavior can help nip it in the bud and also show them that you are in charge. Instead of giving them what they want, i.e. attention, minimising your reaction will get results.
Whenever possible, distract yourself and your child with another activity or simply walk away and let them deal with the consequences of their behavior.
In some situations, not intervening and letting the third party involved (in cases where they are in someone else's territory or comfort zone) deal with the situation themselves can work. Most of us often believe that we are always responsible for our childrens behavior and it is a reflection of our parenting. When your child is old enough to understand the consequences of his/her actions, it often doesn't require any intervention. The lesser attention you give, the easier it is to get them back on track.
For more tips go to http://parentingideas.com.au/