Thursday 15 December 2011

Rules are made to be broken

Through my years as a software developer I have built (or seen other developers built) systems that are very tightly coupled around rules. Very often the rules are explicit and are not my own, but from the business aka “business rules”.

Since it is a rule I start to design the system around the fact that the rule is always 100% true.

But what I do is locking my self in. Why?

Because. A couple of years (or months or weeks) later the rule is no longer 100% true. Very often the same person who told me this rule could never ever be broken is the one telling me to brake it. Since the system is designed around the fact that it can’t be broken, it’s usually pretty (or very) cumbersome to change it.

It can sound something like this.

– Why can’t I do “that” on “this page”?
- Well, because it’s built that way. It is not permitted to do that.
- But I must be able to do that!
- But, you told me at (some date) that it was a rule?
- Yes! But not when I want to do “that”!
- . . .

But it is understandable. We want to be certain about some things when we initially work out the demands for the system. But the users every-day work life is all made up by exceptions! It’s all made up by ways to brake the rules. And if you think of it, it would be a pretty boring job if it wasn’t so. You could easily be replaced by a machine.

And when you think about the rules (laws, morals and ethics etc.) that our society is made up out of. There is always an exception for them. If I where to build a system around some society I would definitely build a strong rule around not allowing anybody to kill anyone else. Most countries have a law for that! But. Depending on which country you live in, it is – sometimes – ok to kill someone. If you find an intruder with a knife in his hand when you come home and he attacks you with the knife, you are (by Swedish laws at least) allowed to kill the bastard (to defend you own life). In some countries *cough* or *cough* states *cough* (not mentioning any) the government holds the right to execute civilians. My system wouldn’t be built around that exception.

What am I trying to say?

Something like; always prepare your system to be able to brake rules. It will happen eventually. It’s hard. I know. It’s much easier to write “if (true)” than “if (true well… but…)”.

Or at least always prepare yourself for it, if you don’t want to prepare the code. And allow it to happen. It’s called being agile :-)