Comment KISS : It's the complexity, stupid! (Score 1) 391
No one here is talking about the one thing that, to me, is the most obvious reason for why software sucks so much: excessive complexity! The more complex a system becomes, the less people understand it and the more hidden problems become.
Many people would agree with that statement in principle, but most people don’t appreciate the scale of the problem. If a system is anything more than dirt trivial, it is too complex and many people won’t be able to *fully* understand it. The problem is that small degrees of complexity in the system results in much higher degrees of complexity in behaviors. It follows a square law or even a cube law--if you double the number of components you may quadruple or more the complexity of the behaviors that can arise.
There’s a general consensus that simplicity is easy and complexity is hard. This is true about *using* something. But when *building* something, in fact the reverse is true: complexity is easy, and simplicity is hard. It is easy to make things more complex. Inexperienced programmers do it every day: add an extra “if” statement, add another global variable, add another flag, add another special case to generic code, add another button or checkmark or option to a user interface. The real challenge is adding functionality without adding complexity. It requires periodically taking a step back and re-evaluating what is common, what is special-cased, and what natural organizations make sense in the structure of the data and the operations performed on it. It sometimes requires complete reorganization when it is discovered the current organization doesn’t work for the new functionality, or redesign when the existing abstractions don’t fit a new feature. It is very hard to make and keep things simple, but the rewards are worth the effort.
If you design a complex program using a large number of global variables and a large number of “if” statements reacting to events, and at some particular moment in time I ask you “what is the current state of your program?” what would be your answer? What does “state” even mean in this context? A program with many global variables and many event-reactive functions employing many if-statements can have a massive array of possible states. An event arrives, a handler function for that event enters numerous if-statements based on both the input event data and numerous variable values, some output is produced, and some of those globals change, placing the code into a new state. The number of possible states is going to be the product of all the possible code paths being taken due to different combinations of global variable values. This product can easily launch into the millions.
I refer to this as “combinatorial code”. (See the mathematical study of “combinatorics.”)
You might think, “this is interesting from a computer scientist writing on a whiteboard in front of a class” perspective, but what does it have to do with me? Here’s what it has to do with you: Have you tested all the possible states in your code? Can you definitively state that your code will behave correctly in every single one of those several million possible states? Could you ever prove conclusively your code is correct?
The part that frustrates the hell out of me is when I see software being made really, really complex FOR NO REASON. I’m working on a project right now, taking an application someone else wrote and porting it to a new hardware platform, and I’m really frustrated because there are layers upon layers upon layers of framework and abstraction, but if you isolate the parts of the code that do “real work”, it’s like 10% of the code, maybe even less. There’s sooo much weight around the real code that doesn’t do anything. No wonder it took a team of people a couple of years to hammer this thing into a workable state before I had the misfortune of porting it to another platform.
It is really easy to make something complex and difficult to debug. It is really hard to not only make something simple, but KEEP it simple after years of new features.