Step 74: The Road to Performance Is Littered with Dirty Code Bombs ~ Kirk Pepperdine

Birat Rai
2 min readJan 7, 2021

--

This is the 74th Step towards gaining the Programming Enlightenment series. If you didn’t learn the 73rd Step, read it.

What is road to performance?

Most of us work in a code that has already been written, and also as we start writing code, because of time constraints or development easiness, we tend to add code which adds debt. Hence, we start to think about performance tuning the code. It’s really very hard to estimate how much time it takes to fine tune the system. Initially, we might estimate it for certain hours, which might end up taking as much as couple of weeks. If only we had a tool to help us identify and measure this risk.

How can we measure complexity and depth of coupling in code?

Software metrics can be used to count the occurrences of specific features in the code. They correlate with code quality. One such metrics is fan-in (fi)and fan-out (fo). With these we can find the instability factor (I) as

I = fo / (fi + fo). 
As I approaches 0, the package becomes more stable.
As I approaches 1, the package becomes unstable.

Fan-In can be defined as the number of classes referenced either directly or indirectly from the class of interest.

Fan-Out can be defined as the count of all classes that depend upon the class of interest.

TL;DR When using metrics one must remember they are only rules of thumb. They can help us to identify and eliminate dirty code bombs before they are a serious risk to a performance tuning exercise.

--

--