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.

Posted in Interesting, Open Source, Programming, Web Tech

Boilerplate code

What is a boilerplate code ? 

In computer programming is a section of code that has to be repetitively used with a little or no alteration . This term is interchangeably used with bookkeeping code.

Can we avoid the usage of boilerplate code ?

This seems to be debatable question. We can’t avoid the use of it all the time as not all the programming languages have the the non-verbosity. Other means to avoid its use is application of meta programming concepts, abstraction, inheritance, keeping the business logic in a separate globally accessible module and reusing it on need basis.