What Does Code Bloat Mean?
Code bloat is code that is allegedly too long or slow on most computer systems. While the term usually refers to source code that is too long, it can also refer to executables that might be considered excessively large.
Causes of perceived code bloat might be use of object-oriented programming techniques where procedural techniques would do, inappropriate use of design patterns, declarative programming and loop unrolling. Solutions to code bloat can include refactoring and eliminating redundant calculations.
Techopedia Explains Code Bloat
Code bloat is a problem in software development where the length of the source code is believed to be excessively long. The term usually refers to the length of the source code itself, but can also be applied to the size of the executable files generated by a compiler if using a compiled language such as C.
Code bloat is often in the eye of the beholder, but it can cause real problems. Long, unclear code can be difficult to read and maintain. Programs that are too large are slow to run.
Code bloat can be caused by inadequate language features leading to excessively verbose code, use of object-oriented design principles where they're not needed and using design patterns that are inappropriate to the problem being solved. Using declarative programming techniques where object-oriented or imperative techniques are warranted can also cause code to grow too large. Loop unrolling, which reduces instructions controlled by a loop, is a programming technique that can boost execution speed while causing code bloat.
Fortunately, there are solutions to code bloat. The first is to avoid it in the first place, by using minimalistic programming techniques, perhaps with software methodologies like Agile programming. The other is careful refactoring, which changes a program's source code while leaving its outward functionality intact. Another good option is software re-use, using libraries to simply program.