Natural Odor of a Developer — Part II

Asara Senaratne
5 min readMay 21, 2017

--

It’s time to know how YOU become the subject of code smell. If you do not know what code smells are please refer the article “Natural Odor of a Developer — Part I

When and Why Codes Smell?

File creation is revealed as the basic point of introduction of code smells. In the case of “Nexus Classes”, the smells propagate by following a sequence of changes done to the file. Complexity always welcome smells. Larger the size of a class is, more vulnerable it is to smell. Files giving out odor inherently lacks in quality. Smells are further created when the source code is added to version controlling systems. Putting this into simple words, a code smells more when the maintenance phase starts. Hence, the programmers won’t be at risk even if they meditate glancing at the code written, prior to a merge. This is because when a smell is to occur, it’s not gradual but spontaneous.

In one way or the other way developers get things working and move on with the next task. It is always worth a second attempt in making the code readable because understandability in code leads to more manageable code with greater performance.

Code smells become the developers’ odor as they are the ones who introduce them. Smells evolve usually in the occasion of a new development or when making enhancements to an existing software. Usually at the beginning, no developer smells his own odor and by the time they start feeling it, the software has reached its release point. Things get messy when you’re under pressure reaching the deadlines. This establishes the point that busy developers with work pressure are more likely to create instances of smells as they find the time for all tasks through shortcuts. If your own code smell is not watched out for from the beginning, you’ll be in trouble as it adds up more work on to your daily schedule paving the way for code refactoring.

Why Bother about Code Smell?

Code smells are created by developers but end-users and third party plugin users are the ones to suffer at large. Hence, if a developer doesn’t give a second thought about the odor they create, their software systems will be deserted in no time generating zero cash flows.

For a moment, set your focus on the end-users. End-users of software, range from basic to experts in their level of computer literacy. Whether a user is a tech geek or a basic user, mobile phones are common devices in use and so are mobile apps. For ease of explanation, mobile apps are picked as it is one category of software closer to end-users irrespective of IT literacy. Code quality is one of the main concerns in mobile app development as it directly affects the performance of the mobile device. A mobile device always runs under resource constraints such as battery life, CPU time and memory occupancy. Empirical search results have proven that fixing code smells in mobile apps have increased UI and memory utilization by 36%. Based on the resource utilization, Google Play Store has labelled 11% of the total mobile apps in a market of 2 billion apps as low quality. Apps extensively rely on reusable classes, third party plugins and external libraries. Hence, dedicated approaches addressing app code quality needs to be developed considering phone specifications and resource constraints such as screen size etc. But this has never been an easy task due to ever increasing user demands. This has led mobile developers to design and develop apps rapidly under pressure. So they tend to adopt bad software engineering practices leading to poor software quality, thus hindering the evolution of apps and degrading the quality of the software and its end-user experience. With the aid of metrics such as frame time, number of delayed frames, memory usage and number of garbage collection calls it is possible to quantify the impact caused by smelly codes on the device’s performance. But no approach is yet created to quantify the effect of code smells on end-user experience. In reality, smelly codes can only make a mobile device tired. The users are affected indirectly when devices with apps suffering from code smells are used. As a result of blighted code, a software could occupy more memory, eat up the space reserved for other apps and further slowing the device. Also it could turn the battery to a hot plate sometimes even causing automatic device shut downs. Frozen screen, malfunctioning app, tortoise speeded device, frequent pop up of “not responding” message are some of the results a degraded mobile app could bring. As per literature on code smells, there exists a negative correlation between the presence of code smells and the app ratings. This is an evidence to prove that code smells adversely affect user experience making the users frustrated.

Third party plugins are small programs added to another program to receive additional functionality. This can be called Code as Infrastructure (CaI) as one piece of code provides service to another piece of code. Code smells persisting in a plugin makes its own self vulnerable thus spreading the smell in the master piece too. From the smells prevalent in the plugin, the base software could also be affected making certain calls between the two pieces of Code abnormal. Since a plugin is developed by an anonymous party the source code may not be available at times, typically in the case of browser plugins. Even though the source code is available, some other developer may not be able to do changes to the plugin as the domain knowledge of the plugin’s development lies with a third party. When plugins are built without eliminating code smells, the users of them become helpless once after the plugin starts spreading the smell as plugin’s behavior is out of the control of general users.

To Wrap Up

Accrued bad smells greatly affects the performance of developers during the maintenance phase. Issues and difficulties in software maintenance greatly rises due to presence of bad code smells. These issues with bad code smells are likely to occur in the long run and coders tend to delay the removal of them through refactoring to avoid drastic modifications to the system’s API. Another reason for the propagation of code smells is the lack of knowledge the developers perceive on code smells. Those who are aware of these problems do not give a priority for smell removal due to work and time pressure and lack of tool support.

As the solution, the code smells can be initially eliminated with code quality checks done at the commit time. Further, adopt recommenders that notifies the software developers of chain consequences on the system artifacts due to changes accommodated in the system. It is stated that refactoring is the solution for code smells. But do assess the impact of refactoring on the source prior its application. Code inspection, walkthrough and peer review activities should be strengthened specially when the developers work under pressure.

Now that you have read the article, open up your code and check how smelly your code is and develop your own perfume to make the code smell good.

--

--