AntiPattern – Spaghetti Code

I love reading computer manuals, be they about software architecture, algorithmic, programming, security, cloud storage and operations, big data, machine learning or others.
The following text is taken from the book “AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis

——————————————————————————–
Root Causes
: Ignorance, Sloth

BACKGROUND
The Spaghetti Code AntiPattern is the classic and most famous AntiPattern; it has existed in one form on another since the invention of programming languages. Nonobject-oriented languages appear to be more susceptible to this AntiPattern, but it is fairly common among developers who have yet to fully master the advanced concepts underlying object orientation.

GENERAL FORM
Spaghetti Code appears as a program or system that contains very little software structure. Coding and progressive extensions compromise the software structure to such an extent that the structure lacks clarity, even to the original developer, is he or she is away from the software for any length of time. If developed using an object-oriented language, the software may include a small number of objects that contain methods with very large implementations that invoke a single, multistage process flow. Furthermore, the object methods are invoked in a very predictable manner, and there is a negligible degree of dynamic interaction between the objects in the system. The system is very difficult to maintain and extend, and there is no opportunity to reuse the objects and modules in other similar systems.

SYMPTOMS AND CONSEQUENCES
– After code mining, only parts of objects and methods seem suitable for reuse. Mining Spaghetti Code can often be a poor return on investment; this should be taken into account before a decision to mine is made.
– Methods are very process-oriented; frequently, in fact, objects are names as processes.
– The flow of execution is dictated by object implementation, not by the clients of the objects.
– Minimal relationships exist between objects.
– Object-oriented talent from industry is difficult to retain.
– Follow-on maintenance efforts contribute to the problem.

First things first, second things never.” – Shirley Conran

TYPICAL CAUSES
– Inexperience with object-oriented design technologies.
– No mentoring in place; ineffective code reviews.
– No design prior to implementation.
– Frequently the result of developers working in isolation.

KNOWN EXCEPTIONS
The Spaghetti Code AntiPattern is reasonably acceptable when the interfaces are coherent and only the implementation is spaghetti. This is somewhat like wrapping a nonobject-oriented piece of code. If the lifetime of the component is short and cleanly isolated from the rest of the system, then some amount of poor code may be tolerable.

The reality of the software industry is that software concerns usually are subservient to business concerns, and, on occasion, business success if contingent on delivering a software product product as rapidly as possible. If the domain is not familiar to the software architects and developers, it may be better to develop products to gain an understanding of the domain with the intention of designing products with an improved architecture at some later date.

…..
Read more on topic in the book from here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: