I have opinions

Broken Windows

There is an interesting theory that came around in 1982 by two American social scientists named James Wilson and George Kelling called “Broken Windows“. This stated that maintaining law and order quickly in urban areas would result in fewer crimes and de-escalating crimes of severity. Their paper stated:

Consider a building with a few broken windows. If the windows are not repaired, the tendency is for vandals to break a few more windows. Eventually, they may even break into the building, and if it’s unoccupied, perhaps become squatters or light fires inside.

Or consider a pavement. Some litter accumulates. Soon, more litter accumulates. Eventually, people even start leaving bags of refuse from take-out restaurants there or even break into cars.
Broken Windows, the police and neighborhood safety

So how does this tie into Web Development? Like the example above, if there are “bad things” in the code then developers will be more likely to further contaminate that file with “bad” things”, because the file already needs a refactor. But that refactor will happen next week/month/year (never, most likely) and everything will be right again in the world. So there’s no sense in doing that now and blowing the deadline for the whole project which needs to be shipped in 2 weeks.

Sound familiar?

This solution doesn’t make sense for most programming languages, but it does for CSS due to its weird specificity and cascading nature. You have a new file for each project named shame.css which contains all of the hacks that you have had to add in order to ship on time. This is great because of several reasons:

  1. All of your hacks are self contained within a single file, not contaminating the rest of the sane code.
  2. You are admitting there are hacks, but each hack should have its own comment saying why it’s necessary, what it does, and how it can be fixed.
  3. Have a spare hour? You can easily dive straight in and fix a hack.
  4. You can see who was responsible for the hacks ($ git blame -l shame.css).

The forth point is actually not a blame game, but you can possibly spot trends. If one developer is making a lot of hacks with regards to, say, the grid system then they may need to be given a quick chat on how it works and what they were doing wrong – this will make them more productive in the future.

It’s also a file where someone who isn’t that well versed in CSS can place a snippet, knowing that someone will come along and implement it correctly in the codebase in the future.