10 Oct '12, 5pm

Holy crap, I blogged! Booleans are baaaaaaad. Here is why:

October 10, 2012 Posted by John Older: Four Guidelines That I Feel Have Improved My Code Booleans are Baaaaaaaaaad First off, did you pronounce the title of this article like a sheep? That was definitely the intent. Anyway, onward to the purpose of this here text. One of the things I have learned the hard way is that booleans are bad. Just to be clear, I do not mean that true/false is bad, but rather that using true/false for state is bad. Rather than rant, lets look at a concrete example. An Example The first example that comes to mind is the ever present user model. On signup, most apps force you to confirm your email address. To do this there might be a temptation to add a boolean, lets say “active”. Active defaults to false and upon confirmation of the email is changed to true. This means your app needs to make sure you are always dealing with active users. Cool. Probl...

Full article: http://railstips.org/blog/archives/2012/10/10/booleans-ar...

Tweets

There is a reason I haven't covered state machi...

railstips.org 10 Oct '12, 6pm

I don’t find this post a very persuasive sell for state machines (although I realize the example was designed to be short ...