Wednesday, 1 July 2009

Not Enforcing Architecture


Dear Junior

As I often enough take on the role of software architect (whatever that is), I am from time to time asked by other architects how I do to enforce architecture, or certain patterns, or coding conversions. They seem to see a problem that they spend a lot of energy and effort in defining these rules or guidelines, and developers in general seem not to follow the rules, so how to enforce them?

The question always takes me aback. Besides really not recognizing the scenario, I really have some trouble with the question itself, especially the usage of the word "enforce".

To start with, if you believe in that there is something like "free will", you cannot enforce anybody to do anything. From a philosophical perspective anyone is always in a position to say "no" - of course taking the consequences, but still refusing to be forced. The only way to really force someone is to ensure that the consequences are catastrophic, so that refusing is not an option. Total annihilation of mankind would be such a scenario. Or, from a personal perspective, pointing a gun to someone's head would suffice in depriving them their free will, thus enforcing some behaviour.

Well, pointing a gun to the developer's head will probably not be a feasible way to enforce some coding standard. In particular it has the drawback that you can only enforce it at one programmer at a time, or two if they are seated within arm length distance and you have two guns. Apart from that, I think it would be illegal in most countries I have worked.
So, the programmer must follow your architecture out of free will taking into consideration the consequences of not adhering. Let us get back to this later.

Secondly, the word "enforced" is normally most used in the context of "law enforcement" or "enforcing legislation" referring to the power of police, courts, and the rest of the system of justice to uphold the rules of society - which is usually considered to be a good thing. Let us pause for a moment and consider why this is considered good, even though it is a restriction of our freedom of choosing our actions. The legitimacy of the legislation in our democratic societies derives from the fact that it has been decided in an open process after careful discussion and debate between delegates elected to represent the people being governed by the laws.

So, how often does this structure apply to the relation between the architect, the architecture, and the developers? Is the architect elected by the developers in free elections, and the architecture debated and voted upon? In most of the cases when the architect asks for advice on enforcement, the answer to these questions is always "no" in my experience.

If we are to find a government system that resembles the structure of most organisations with architect and developers, it is despotism that is closest. The despot makes decisions he (most of the cases) consider wise, the subjects have no say in the question and must obey. Of the different kinds of despotism, the situation is actually best matched by a kingdom where power of the king stem from a higher power (i e a God in historic societies, and Upper Management playing that role in development organisations).

I am sorry, but if someone asks me for advice on how to enforce legislation in a system of one-ruler dictatorship - I will simply discretely not cooperate.

Back to the free will and making people follow rules. If you do not point a gun to their head, the reason for developers to follow "your" architecture is the consequences of not doing so. The architect might get angry at them, they might have an unpleasant discussion with the boss, or they might eventually be fired. Basically, they will follow the architecture out of fear. And, having seen quite a few teams in various situations I can tell, fear is not the best motivator for producing high quality software.

So, at the bottom line: I will not enforce architecture. I will not help enforcing architecture. I think it is a bad idea to enforce architecture. I think that if you want to enforce architecture you are working in the wrong direction.

Do not enforce architecture. Do not even consider doing it. Find a better way instead.

Yours

Dan