3 ms·
In my experience there are two main causes of code bloat. One is that people use abstractions that are more verbose than necessary. The fact this is bad is pre
by underwater 11y ago
In my experience there are two main causes of code bloat.
One is that people use abstractions that are more verbose than necessary. The fact this is bad is pretty uncontroversial. Though very few people go out of their way to write bad code, it's just that everyone's view on the right amount of abstraction is different. What's fine to you might look like gibberish to me. I've radically simplified code by converting complex regexes to multiple steps, for example.
The other cause of bloat in mature code is the inevitable bug fixes, feature requests, and edge cases that accumulate over time. Having the attitude that a system is unnecessary complex is dangerous because you don't know which of these edge cases could doom your rewrite.
Even if you do manage to ship a simplified version of the system it's incredibly difficult to maintain the pristine state of the system. Unless you devote all your time to playing code police then cruft will creep back in when others touch the code. This is where having more abstractions can actually help, because good abstractions limit the impact a bad piece of code can have.
- jandrese 11y agoExcessive abstraction might otherwise be called Enterprise Class Code Syndrome.
- paulddraper 11y agoYour post begs for a definition of too little abstraction.
- EvanPlaice 11y ago'The Unix way' would be an example of too little abstraction. Sure it's great to have lots of little single purpose applications that can be mixed/matched in a variety of different ways. But... If everything in a system is built based on that premise, eventually the OS just becomes a lousy abstraction for a global namespace. I think it's important to strike a middle ground. Build tools that work well for solving a 'class' of problems, then include public interfaces so they can be re-used for the higher level composition of systems.
- greenyoda 11y agoI've also seen code bloat due to insufficient abstraction: the programmer fails to realize that a lot of things in the code are instances of the same thing that can be factored out into an abstraction.