Posted in Interesting, Open Source, Programming, Web Tech

Spaghetti code

Imagine a bowl of cooked spaghetti and you manage to take a few of its strands on a fork. Unfortunately, few fall back to bowl. Now, trying to search for which is the longest string or the start point of it. Quite a task. Isn’t it? Analogically, this is what happens when we have a spaghetti code.

What is spaghetti code?

Spaghetti code, as the name says it is an unstructured, complex and tangled nature of  source code which is troublesome to maintain and comprehend for fellow programmers.

How does it get introduced?

Not implying the design patterns expected for a programming language per se.

The code starts simple but as and when new features get appended for the sake of scalability not understanding the existing code can introduce redundant code and looping/jumping of program from one to other, back and forth. Also if multiple developers work simultaneously problem can be worse.

Overuse of workarounds to serve the purpose of functionality for time being and never refactoring it.

Is spaghetti code avoidable?

Yes. It is definitely avoidable if as a code developer we use more readable variables and provide comments to make it comprehensible.

Before beginning writing new feature understand what the existing code does and is it possible to tweak it a little bit to improvise new feature.

If there is a reusable code block its a good practice to isolate it in a function construct and make a call from other code block on need basis.

Author:

I'm really glad that you stopped by. If you like blog posts feel free to follow, like, share, comment etc. If you have any suggestions or would like to learn or understand any topic, you can always write to me. I believe that, reading and writing heals and fuels the soul 🙂 Keep visiting and happy reading 🙂Twitter handle @_ViniTweet_ Cheers to You! ♥

One thought on “Spaghetti code

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s