Article 6GBZ0 CodeSOD: All Roads

CodeSOD: All Roads

by
Remy Porter
from The Daily WTF on (#6GBZ0)

A conditional statement represents a branch in our code. A place where things could go one way, or they could go the other. That, at least, is traditionally what they are. Adam's co-worker took a different approach.

if user: if user.is_owner(): self.template_values['login_url'] = users.create_login_url(self.request.uri) else: self.template_values['login_url'] = users.create_login_url(self.request.uri)else: self.template_values['login_url'] = users.create_login_url(self.request.uri)

Like a lot of Python code, we start with a null check- if user is not null, we check if they're an owner. Whether they are, or not, or whether the user variable is null, or not, we do the same thing in every case: set a login_url value.

Adam is on "code maintenance" duties, and is afraid that he'll have plenty of maintenance work going forward.

buildmaster-icon.png [Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments