Saturday, March 31, 2007

The shield of YAGNI

YAGNI (you ain't gonna need it) is a good principal, but like anything, too much of a good thing isn't very good at all.

Yagni is a tool to keep us on track, to help us make decisions and guide us in our development. Like any other practice, it does not stand on its own without logic and reason. Sometimes its thrown around like my parents used the phrase, "because I said so." And while that works well for a crying three year old who wants to stay up late, any catch all phrase is dangerous.

When I am writing code, I add abstractions I don't need. You can argue this goes against yagni, because you don't need it (and you ain't gonna).

These abstractions are not there to support behavior that may exist in the future. They are added because, when things change (and they always do), it has ALWAYS been a lot more painful when they did not exist.

There is a very distinct difference between this and adding extra functionality or abstractions to enable change you think will happen.

This is an important difference.

Next time you are having a discussion and yagni is brought up, think about which one is driving what you supposedly don't need.

1 comment:

Anonymous said...

Sounds like keeping a good Seperation of Concerns.