Spaghetti Code

This anti-pattern is the most common and classic version happens across different layer of software. It shows incompetence and very little code structure in the project to the extent that it lacks clarity and must depend solely on the original developer.


Exception

  • When the poor codes is small and controlled in the project and the cost of refactoring such codes are costly than retaining them. A small amount of poor codes are tolerable justifying with business values.

Consequences

  • Project is not maintainable and deprecated once the original owner abandoned the project.
  • Unrecoverable project if this anti-pattern is overly severe.

Symptoms

  • After code mining, only part of methods and objects seems suitable for reuse.
  • Methods are very process oriented; in fact, objects are named processes.
  • Flow of execution is dictated by object implementation, not by the clients of the object.
  • Minimal relationship between objects.
  • Many object methods has no parameters.
  • Use of global variables for processing.
  • Talent is very difficult to retain.
  • Object-oriented traits like polymorphism are not used in object-oriented approach.
  • Modules libraries are not use to organize functions in non object-oriented approach.
  • Follow-up maintenance causes more problem instead of contribution.
  • Cost of re-writing the project is cheaper than maintaining/enhancing the existing version.
  • Improper use of goto statement.

Causes

  • Inexperience with the technology at hand (object-oriented / modules architecture planning).
  • No mentoring in place.
  • Ineffective code reviews.
  • No design prior to implementation.
  • Frequent results of developers working in isolation.

Fixing Recipes

  1. Access the damages and plan for action
    1. Either refactor (if it is reusable) or
    2. Spin a new version to deprecate the existing version
  2. Write the test suite to lock the existing expectations.
  3. Plan carefully with architecture. Search for do, and do not from the existing projects.
  4. Refactor the codes over-time.