DEV Community

Discussion on: Code Smell 145 - Short Circuit Hack

Collapse
 
rgails profile image
Ryan Gails

My big issue with this is debugging it. Did we not log in because we have no user, because the user isn't valid, or because isValid returned null (which seems like something you'd want to handle in a particular way IMO)? A single line getting the job done is great until you're ripping through 20 lines of chained methods trying to figure out where things went wrong.

I agree with Ben that it's fine to get deep values with though. Especially if you really just care about whether or not you could get to the value you were looking for.