Sloppy Code As a Silent Business Killer

 |  Writings

And how to fix the issue.

Contents

Sloppy: chaotic, careless, cowboy-coding, spaghetti code, lasagna code (see below).

Is Sloppy Code Bad? Why?

Visual difference (Juxtapose, see sibling images).

Sloppy code is excessively complex. It overloads the human brain's cognitive capacity with much more than optimal 1 3-5 notions at once. That prevents brain to make good decisions ending in bad decisions.

Sloppy code exposes the reader (and writer) to all concerns at once. View, viewmodel, data, business logic, UI logic, problem domain notions, security domain notions, HTTP domain notions, language specifics, different problem domains mixed, different objects responsibilities mixed, different application layer mixed, conditional behavior, edge cases, corner cases.

The above passage has already overloaded your brain as well as the sloppy code does.

The core issue is the human brain momentary cognitive capacity is very limited. Above 3-5 interlinked notions it cannot make quick and robust decisions.

Writing clean code is a continuous decision-making process—like crafting concise, meaningful prose.

Writing sloppy code means taking rushed or overloaded decisions due to being in the brain's constant cognitive overload mode.

Reading sloppy code is like reading excessively wordy texts jumping from one subject to the other, and then to third one, later introducing concepts that should be introduced earlier, introduce new terms with no meaning clarification, add here yourself.

[NB] Non-momentarily the human brain capacity is practically endless in all dimensions - width, breadth, depth. Trained for automatically correct decision-making it is a lightning-fast while being masterful.

No problem. I write sloppy code so far and then write clean.

Yes Problem 1

Other people will read your sloppy code.

It is not your problem but others might struggle to digest it — figuratively speaking :)

Yes Problem 2

The sloppy code spreads like a virus — except the infected keep coding.

The inability to write with literacy prevents people from continuing in high school and get good-paying jobs. But writing sloppy code still is well-paid for. Writing sloppy code is much easier compared to writing clean code (like compare a couple of months with roughly years of continuous deliberate practice). To keep writing sloppy the sloppy coders proclaim it is how the code should be written.

Yes Problem 3

Sloppy code is a habit. Once a person is used to it, they always do it.

Thinking is a skill that is trained. The brain provides you with what it considers easier to provide. Whether it is sloppy code or clean code. Thoughts with more accumulated repetitions is what it considers the easiest to provide.

If you trained your sloppy / clean code repetitions 50/50 the brain will provide you with this "soup".

Complete re-learn is impossible cause brain does not forget things. If you spent several years thinking in sloppy code (read "number of repetitions") re-learning will take times x years. And yet finally it will provide you with partially sloppy thinking. Learn clean from the first time. Repeat clean.

Yes Problem 4

Businesses suffers massive, often unnoticed financial losses on sloppy code. And they hardly ever discover it (NB: Third Order Ignorance 2) on their own.

The systems with sloppy code will work (after the money the business wasted on debugging and fixing issues in production). And that is the problem of business hiring sloppy coders. This problem is carefully prevented to reach that business decision makers.

There are some more consequences of this.

  1. Sloppy code often translates directly into wasted money. In constantly changes business conditions sloppy code cannot adopt the pace and scope of changes. After a couple of round of changes (roughly months to a year of product life) it becomes unmanageable throw-away. The sloppy coders team leaves blaming the business for being "misaligned". And business stays with a throw-away product.

  2. Sloppy code invites negative selection. Professional programmers go away when suggested to accept sloppy codebases. New sloppy programmers take place of the former ones. Just the angle and details of sloppiness would change. They will be silently replacing the former sloppy code with new sloppy code3 wasting business money (=time=opportunities). After another year the product dies not matching the demand. Whether it got over break-even and paid back the initial outlay is the business problem, not sloppy coders' one.

  3. Developers accustomed to sloppy code are satisfied with this way of things and always proclaim that sloppy code is the special sort of a good code.

  4. Uninformed businesses are also satisfied with upfront savings, unaware of the long-term costs until it’s too late. But that is not problem of sloppy coders :)

Yes Problem 5: Specific Case for New Products

When a business starts building the new (digital) product it is always an exploration and experimentation to understand the product domain. Each iteration reveals the new requirements, discards earlier assumptions, changes the perspectives. That requires the code to be maximally flexible to painlessly adopt any change arising.

Sloppy code is brittle and rigid. It hardly withstands 3-4 change rounds before it becomes the unchangeable (time + money + learnings) throw-away. Ever heard techies are reluctant to change things? Thats because of it.

A Tale of Two Projects

From Wiegers K., Software Development Pearls (2021), PDF version, p. 200 (as well see my review), A Tale of Two Projects:

To illustrate how poor quality lowers productivity, let’s compare two real projects from the same company, as related by consultant Meilir Page-Jones, who worked on Team B. This company’s IT department concurrently developed two new core, high-availability applications to replace twenty-year-old legacy systems. We have two projects, two teams, two approaches, and two very different outcomes.

Team A started large and grew even larger. They met their deadline by adding several developers and testers and working a lot of overtime. They ran 50 percent over budget, much of which they spent on debugging in the months before delivery. Following delivery, Team A received at least one message daily from users that their system had crashed or “done something mysterious.”

Team B started very small and grew, though not as much as Team A. By the targeted completion date, Team B had a working but incomplete system. They required two more months to deliver the finished system, which put them 20 percent over schedule and 10 percent over budget. The system worked well and generated only a few undramatic enhancement suggestions

Several months later, an audit discovered that System A’s mysterious problems were due to a massively corrupted database, which had been accumulating bad information for months. A manual cleansing proved futile. The database was soon corrupt again; no one knew why. Team A did an ugly reversion to the legacy system they were attempting to replace while they totally overhauled their new system. Within a few months, though, their system wouldn’t restart at all; the company finally scrapped it as irreparable. They launched a new project to rebuild System A—with Team B’s manager at the helm!

Now in details on waste: sloppy code cannot accumulate learnings due to 1) it cannot convey purposes, is a throw-away and 2) because of negative selection (Problem 4.2 above): the future coders will be sloppy ones that will have to learn the product second time. And that repeats with their followers.

Clean code loves changes. It is meant to deliver the value that way, adopting changes eagerly and rapidly.

How Businesses Can Prevent This

Some do not care and do not care to know. Some do not know and it is too complicated for them to understand. Yes it is complicated.

Some care and want to understand and I wrote this one and other materials here for them. It can be explained and implemented. But that requires desire to improve. The sloppy code is a disease — but the cure is well within reach.

How to Clean Code?

SRP, SoC, information hiding, encapsulation, isolation, modualarization. No code smells (1, 2) or design smells, explicitly managed technical debt.


Sloppy Code Attributes

  • Highly interdependent code: Functions, classes, or modules are deeply intertwined, making it hard to change one part without affecting others.
  • Unstructured flow control: Deeply nested conditionals;
  • No modularity: Code lacks separation of concerns, resulting in everything being packed together.
  • Poor readability: Variable names, functions, or logic are not intuitive, making it hard to understand.
  • Maintenance nightmare: Fixing or updating the code risks breaking unrelated parts due to its chaotic nature.

Footnotes

  1. Miller G, The Magical Number Seven... (1956)

  2. Third Order Ignorance - Lack of Process: I do not know of a suitably effective way to find out that I don’t know that I don’t know something.

  3. Note there is endless number of sloppy code implementations while clean code has 3-4 faces, not more.