TDD Pro-Tip: Suspect Sentinel Returns | #11

PawCast with GeePaw Hill - A podcast by GeePaw Hill

Categories:

"Now, there are no bad dogs. Sentinel returns aren't inherently evil: there are two reasons why they're ubiquitous down there at the bottom of your stack, a cut or two above the metal...But every sentinel return in your code is a guaranteed explicit branching construct in that code. In the string find case, for instance, you can never use the answer blindly. You *have* to branch around the possibility of the sentinel saying "no love here". I don't desire explicit branches. They make me think, and mama dint raise no thinkers. When I *can* find a way around them, I do. The trick, as with most coding constructs one's unhappy with, is to see if you can wrap it so that it works in your context but so the branch is effectively hidden from view almost immediately, level-wise."  Episode 11 is now live. If you have any feedback you can always tweet @GeePawHill on Twitter, or drop a voice message via the voice messages link here on Anchor. You can also read the full transcription of the podcast over on GeePawHill.org.