Natural Odor of a Developer — Part I

Asara Senaratne
Engineering at 99x
Published in
5 min readMay 11, 2017

--

Not sure if it’s your code that smells bad or your own self? Sounds odd? Just keep reading.

Have you got the nose for coding? Do you watch out for warnings? Do you feel that your code stinks? Can your code be read by Homo sapiens? If “NO”, then this is for you.

Code smell reflects poor programming aesthetics which cannot be sniffed via testing techniques or coding metrics. This reflects a bigger problem on the surface level which is necessarily not a software bug. Code smell arises due to anti-design patterns or due to violations while adopting a design pattern. In simple terms, smelly codes raise the need of code refactoring. But to make yourself feel better, keep in mind that code smells do not prevent your program from functioning, rather it makes your source code vulnerable.

BAD CODE SMELL != PROGRAMMING BUGS

Do you wanna know how? Scroll down to read about the types of code smells that you probably would be creating.

Puffy Codes

Puffy codes are largely fatty, lightly salted and fleetingly smoked. These methods and classes evolve to be gigantic portions of code which are hard to work with, making the life of a developer hard. This smell usually does not harvest in a night, rather it gets accumulated with time as the program grows and yields well, when no one attempts to solve it.

  • Humongous classes

A class having too many methods or lines of code

  • Lengthy Methods

What if your method starts questioning you? Don’t be surprised, it definitely will, when the method grows out with too many lines of code

  • Primitive Mania

-Simple tasks denoted by primitives instead of small objects (such as special character in NIC, Date of birth etc.)

  • Information being coded with constants

-Arrays with string constants

  • Unending parameter list

“Ouch! I can’t handle too many parameters. Let me breathe”, says a method to a coder. Do not overload a method with parameters. Usually 3–4 comes in handy.

  • Data Clusters

Won’t it be nice, if we converted pieces of code referring to the same task/variable into their own classes?

Object Oriented Culprit

Object orientation is a programming paradigm loved by all tech geeks, due to its relative simplicity in application. But incorrect and incomplete application of object oriented principles will make your code stink too.

  • Many choices

Block of code with a sequence of “IF — ELSE” statements setting off a hundred and one choice to select from

  • Fleeting field

A field which gathers data, only at certain instances and acts as a loafer when it has nothing to do.

  • Snubbed Inheritance

This refers to a subclass that does not make full use of the methods and properties gifted by its parent. These unused methods are like baby sitters killing the inheritance hierarchy.

  • Friendly classes

This is about classes providing identical functions but under different method names.

Change Blockers

“You wanna make a change in me? Well then you’ve gotta change the same in my followers too”. This means a small change in one place requires an array of changes to be done in other places. Change blockers make the life of a developer hard, generating a much more sophisticated code than what was initially written due to constant changes that have taken place in the code.

  • Diversified change

Changes to a class make it necessary to change many unrelated methods. As an example: When adding a student record in a student management system, you have to change the methods related to course allocation, batch allocation and attendance recording.

  • Bird mouth

A simple modification followed by many small modifications in many different classes.

  • Unending families

Creating a sub class for one class makes it a necessity for creating sub classes for other classes.

Dischargeable

Dischargeable piece of code can be removed from the code to make the code look much prettier and cleaner. These are usually unwanted crap whose absence will give the code some fragrance.

  • Comments

Make sure you write comments in your program for another developer to make sense out of your code. Do not convert comments into a lullaby.

  • Duplicate code

A program code doesn’t need a twin. Hence, avoid identical code fragments

  • Sluggish Classes

Classes that are lazy and cater no big purpose should be deleted as a class alone is expensive with regard to time and money.

  • Late Mr. Code

Any single parameter, variable, method or class that’s no longer in use.

Nexus Classes

Nexus resembles aggressive coupling among classes or delegation of work among classes.

  • Feature Greed

A method accessing another method’s data, more than its own.

  • Unfitting Tenderness

Fields, methods and attributes of one class being poked by another class.

  • Memo Series

In-class series of calls for methods in an unending chain.

  • Man in the Middle

Do you think you need a class to just perform one task while it chills delegating the rest of the work?

To Wrap up

Code smells are symptoms of poor design and implementation choices. The extent to which code smells tend to persist in a software determines the severity of the side effects such as increased need for change, fault pop ups , decreased software understandability and hardships in software maintainability. However, to the best of my knowledge, there aren’t any empirical evidences showcasing when and why code smells occur in software. When a deep investigation is made on the software industry, it is obvious that instances such as urgent maintenance requirements, prioritizing profit generation over quality and pressure on the development team to make a quick release are some of the causes of bad smell in software code. Keep in mind that code smell do not only occur in the source code, but also in software lexicons while affecting the system artifacts such as test cases you write.

To make it simple, stating what is and is not a code smell is subjective. It varies by language, developer and development methodology followed.

Natural odor of a developer comes to an end with this little introduction. But jump on to “Natural Odor of a Developer — Part II” to read how “YOU” become the subject of code smell.

--

--