Dead Code...
Thanks to my friend Rustam Mehmandarov , I had the opportunity to speak at an internal event at Computas in Oslo (https://computas.com/en/).
The topic of this session was all around legacy and dead code and how to get rid of it.
There is legacy code which in principle is code where for example the original developer is gone, no documentation is available, nobody would like to touch it or simply code you are afraid to touch.
To make that clear, legacy code doesn’t mean it’s bad code…but it could be.
If we talk about dead code, we usually talk about code like unused imports, constants and variables. Or code that is unreachable. This kind of code can be found by leveraging the power of todays IDE’s and they are really good in finding that these days.
The harder to find code is so called zombie code, which is code that often is covered by tests and that will be maintained but in fact is never executed in production. The question is how to identify this code?
Well there different tools that you can use like for example JaCoCo, vFunction, OpenRewrite and also Azul Intelligence Cloud. They mainly all use different approaches to find dead code. Intelligence Cloud for example can either be attached to all OpenJDK based JVMs (Java Virtual Machine) by using a lightweight java agent or run directly from any Azul JVM like Zulu or Zing.
领英推荐
A cloud service will collect and aggregate usage data at runtime in production without and overhead.
This information can then be aggregated and merged with data from the application jar(s) using a client? tool.
From this you can get a report that shows you all jars/classes/methods that are used and unused to help you finding dead code.
To have reliable data, it is important to collect data over some time before you do a report (e.g. 3-6 months) to make sure all used code was touched.
The nice thing about Intelligence Cloud is that it also offers information about vulnerabilities found in #production which is quite unique.
All in all it was a great event and a pleasure to present at Computas AS . ??????