I consider Code Quality
to be everything related to code that helps us deliever better, well tested products.
Everything has an expiration date, even code.
In this post I want to talk about how to take into account the lifetime of code in the design process.
High level code abstracts core concepts for programming.
It’s easier to replace whole concepts like switching From TCP
to UDP
.
The more “high level” code is , the easier it to be replaced and changed.
The usage of code may consist of few things:
The level of code quality is correlated directly to the amount it will be used and vice versa.
When we write a simple batch or a script we make all the mistakes that we ourselves would dismiss in a code review:
1 | import os |
This is a simple script that was written to delete some files,
What are these files, what created them, what id 0 means - these are all the question that the code won’t tell us.
Because it was probably was written for few usages and that’s it.
Scripts tend to live a short amount of time therefore we don’t invest time in them.
Tools are higher level scripts.
The difference is, tools tend to provide easier and configurable API for the user or other scripts.
The tendency is to cut corners in the code base of the tool - for sake of fast development and faster changes for the requierments of the tool.
The counterpart for this assumption is the amount of time the tool is needed to be used or changed.
If it’s expected to be used and extended in the future, design time should be invested.
Else it’s not necessary since the the tool will be discarded any time soon.
Applications tend to last longer therefore a proper design is needed.
To accomodate the needs of the clients/buisness there’s a higher magnitude of design needed to plan and construct the software.
This is derived from 2 planning steps:
Libraries, especially core/standard/infrastructure libraries tend to live long.
Applications are constructed on top of the core libraries.
These apps earn money, core libraries are dependent on the revenue to be maintained and constructed.
This is why it should be important to design it carefully.
When the core libraries are written in low level code, such as C
it will live longer since lower level code costs more to maintain and build.
There’s a direct proprtion between Code Quality and code TTL.
Higher expected TTL means we need to invest more time in code quality.
Higher code quality means we expect the code to live longer.
It’s not necesserily means that if we want the code to live longer we need to invest more in its quality.
Code needs to serve a purpose - if we want the code to server its purpose longer, we need to make sure its quality is great.
Each category affects the lifetime of the code and vice versa.
Usage:
When code is no longer used it served its purpose, a WebAPI that is no longer needed may be discarded.
Role:
The lifetime of an assignment ends when the student recieves grade on their assignment.
Purpose:
A generalized version of the code may eliminate the need for specific code implementations.
Audience:
If an open source is no longer used by people - although it may be a great product with high quality code - it will be discarded.
Technology:
If too many Technologies are integrated into a solution, a smaller customer may not want a “big” solution.
Expertise:
If code requires crazy amount of expertise - it will be considered to just throw away everything at some point.
So how does the lifetime of code affects your code?
Thanks for reading!