Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

The status antipattern

In a new blogpost on vemv.net the author (I couldn’t find his real name) argues against using a simple status field.

Dear programmer, do you ever use the name state for your variables? Like state = 42?
“Hell no, that’s a terribly generic word. Better to use the domain-specific wording the variable refers to: is_invoiced, visit_count, shopping_cart, things like that.”

Sounds reasonable. But sometimes, you have a database column called status, and use it through your codebase, right?
“Yes.”

Were you aware that status and state mean basically the same thing in English?
“Uhm…”

https://blog.vemv.net/the-status-antipattern-479c26c7ddf7

Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band.