What makes code maintainable?
an list of attempts to make code better. not an "end of all knowledge" list, but evolving and living with times.
I have thought these for a while and better to make a post of these than just ponder inside my homogenic head.
Clear (minimal) interfaces
Interface embodies an abstract requirement, that implementation fulfills.
Minimality tries to ensure the coherency of the concepts/interface, as humans do have limited capacity to reason and understand concepts.
Clear concepts.
The definition of a concept is different for each person, depending on experiences and culture. I think the only way to make an abstraction/concept concrete and clear, is to make it clear to oneself by implementing, reading, testing, and by documenting.
Clear apis
Boundaries, is this a stand-alone api, or part of some other group, is it a whole, or a part. Is it independent of any other apis. Connections, usage, modules.
Self documenting naming
naming is one of the big 3 problems of software engineering, for example often great sounding naming scheme, but actually quite horrible is:
- everything is a "Manager"
- naming variables according to what class they are "UIButtonTextObject uiButtonTextObject;"
Consistent coding style
If each line of code has different style, programmer spends more time decoding code into mental models, codified coding style helps with read speeds and helps mitigate coding errors.
Tests
Tests of/on interfaces, Tests of whole (integration tests), unit tests.
Comments
Comments on weird/Complex code. For example if the code has had to have construct where the indexing starts from 0, but skips 1; 0,2,3,4,5,6 being valid numbers.
Documentation
Examples and usage examples.
CI Building
Continuous builds of the product and creating internal releases constantly, instead of panic mode building on release day.