The invisible lift
The story goes that when the building was built, the organisation taking the top floor demanded their own lift that would not stop at any other floor. They got their wish. Entrances to the lift shaft were blocked off on every floor except the ground and top floor. End of story? Not quite. The floor indicator and call buttons were installed on every floor.
Do you build invisible lift openings when you build software? Install buttons and indicators in the anticipation that they might one day be needed. (Ignoring the fact these are mere details hiding the bigger picture… doors for example). This is a good example of YAGNI, you ain’t gonna need it. You don’t need a lift floor indicator and call button until you’ve got an opening to the shaft and doors. And when you need those lift technology will probably have moved on and the buttons and indicators will be all but obsolete.
Times when I’ve violated YAGNI without regretting it are when I’ve evaluated the cost of doing something later, and the cost of doing it now, and found that the latter is lower.
To be more scientific, I’d have to factor in the likelihood of having to do that thing later.
[…] So, there’s a few of us at work these days that have started looking at dead code in our system. We run into all the usual culprits: functionality only half removed, code only exposed for the sake of unit tests, complexity added for the sake of “Patterns” or just cause it seemed cool. I’ve seen some pretty fantastic YAGNIs in the last couple of weeks. Some of them I can honestly say I added, or was at least involved in the creation of. So when I saw this today, it really made me laugh. A RemoteObjectProvider used only by unit tests has NOTHING on elevator equipment in the off chance you want to add a door… […]
That is the BEST YAGNI I’ve seen in a long time. All you need now is a windowless fire escape and you’re set.