He isn't making a legal defense.
He is putting the judge on notice that he knows what the game is, which tells the judge that he has two realistic choices:
- Dismiss the ticket out of hand to avoid any record of what is going on
- Let the hearing proceed as normal and risk letting any and all law enforcement that is there getting a glimpse into what is really going on (as well as any onlookers... but cases for people that they know are going to be problematic tend to be somehow scheduled to take place once all other cases have been dealt with).
The judge took the easy (and smart, IMNSH Opinion) way out and simply dismissed the case out of hand, completely avoiding any potential record containing publicly queryable information.
Sometimes the best defense is letting them know that you know the game they are playing.