Wednesday, July 10, 2013

Keeping new things clean in a dirty world

Most software projects are unhygenic. Organization is poor, some scripts don't work, and it's likely that many or all of the test suite doesn't work, either. Very little is automated and nothing is documented. It's the software equivalent of living in a fraternity house. You have to carefully walk through the mess in the living room to get from the filthy kitchen to your disaster of a room.

No-one sets out to live in a dump, just like no-one sets out to work in a disaster of a software project. Little things add up, like that pizza sauce stain or where someone fell drunk against the wall. People tried to clean them up, but it was never the same. And they add up, day after day, until you can't see the walls for the empty beer bottles. And you're not sure what you can do to make a difference, short of condemning the whole thing and starting from scratch.

We can see exactly what is wrong with a fraternity. No-one in the fraternity is focused on cleanliness - on hygiene. If a dish falls on the floor, no-one makes it a priority to pick it up. If it is picked up, then it's not put away in the cupboard. If it's actually put away, then it was put away haphazardly, without stacking nicely. And if, by some miracle, the dishes were actually stacked, it's only done the once. The next time, the dishes will be left to mold in a corner on the table. No-one cares.

There are fraternities where everything is kept neat and tidy. I lived in one (well, mostly neat and tidy). But, it requires twenty-somethings to do something they tend to not do - focus on their environment over themselves. It requires someone who takes charge and chivies everyone else to work at it. To make the big push to clean everything up. To spend their Sunday cleaning instead of sleeping off last night's party and cramming for tomorrow's exam. So that the house can start the week of neat and tidy.

Even that doesn't work. I can see some of you rolling your eyes in memory. Everything does get clean, but does it stay clean? Of course not. Because there's nothing in place to make sure that the work done remains done. There is no ongoing maintenance.

The root is that the house wasn't what needed cleaned. Yes, the beer bottles and pizza boxes needed to be thrown out. Yes, the dirty dishes needed washed and put away in nice stacks. But, the real problem was the mindset that let everything slide. The real fix is in retraining everyone in the house to feel uncomfortable when something is out of place, to itch under the skin when a dirty dish just lays on the end table. If nothing else is accomplished that Sunday afternoon except to fix that mindset, then the house will clean itself, as a matter of course.

So, when you add that configuration file to support the new module, don't just throw it anywhere like everyone else seems to have done. Put it where it should go. If you have to write a script to make sure it's shoehorned into the dirty way of doing things, then so be it. At least you have kept this small part of the house from being dirty. And, you have paved the way for someone else to clean up a piece that was dirty. You have started to create the itch for hygiene.


  1. I had a very similar thought.
    I noticed whenever I enter a new situation where there is code I know nothing about.
    I constantly look for cues on how to approach.

    Function & variable names for context.
    Also how they name their variables & functions
    Do they use any type of prefixes or suffixes?
    How the comments are laid out.
    Are they are using 4 or 2 spaces for indentations.
    In others words I am looking on how to behave in my new environment by looking at what was done before me.
    Just like how we look for social cues in order to know what is acceptable behaviour.
    Yes there are times I just say to the hell with this I am doing this my way.
    However most of the times I just do what everyone has done before us.
    Sometime changed when I came a across some horrible code dealing with configuration files.
    To much copy & paste lots of duplication No consistent naming things that could be easily placed in a parent class was not.
    So it was just a big mess.

    One example each config file class had a different method to write the config some examples write_network_config, write_authentication_config.
    I said screw it I am going to do what I feel is in my best interest and the company's.

    So I took my time and refactored the config file handling.
    I was able to reduce the code by quite a bit.

    Now it easier to add new features, fix bugs and blah blah blah.
    When someone else has to use my code it extremely easier for them to follow. Even though I had very little documentation written.
    Also since it was easy to follow the style I use was maintained.
    There are somethings I am going to rework later.

    There is still a lot of things to do but I am enjoying it for now.

    I believe most people will do the "right thing" if is relatively convenient for them.

    However people are generally going to follow the path of least resistance and do what everyone else had done before them.

    However once they start seeing how clean things are and how it makes their life easier in the long run they will convert.

    The way I see it the biggest gains are obtained by figuring out how do we make it easier for people to do the "right thing".

    1. I think that's the trick - how can we make it easier to do the right thing than the wrong thing?

      Thanks for the comment!