See the null object pattern.
Encapsulate all such behavior you&#x27;ve mentioned with appropriate OO patterns, and stop writing procedural code spread all over the place that has to rely on comments to inform you about the right way to handle the bad data. Handle the bad data cases simply and specifically.<p>Feel free to add some code that explains your use case and where you think such comments are required...