Public acknowledgment of the students misbehavior puts the student in the spotlight. By handling it after class or in the hallway the student will only be gaining your attention, not their classmates. Another reason for handling it privately is that by dealing with the matter in class you've interrupted your lecture. A good method for disciplining the student and not interrupting your class is to simply ask the student to see you after class. The students imagination will work wonders in a situation such as this, and the behavior will generally stop.
Communication is an essential part of classroom management.
The teacher talking and the student listening is only one small aspect of communication in the classroom. The teacher and students' actions, facial expressions, tone of voice, and other nonverbals create a whole realm of communication that the teacher must be aware of in order to communicate effectively. It must be stressed that communication involves not only speaking, but sometimes more important, listening. By using active listening it is possible to create a more problem solving environment rather than an antagonistic one. It's relatively easy to do.