DEV Community

loading...
Cover image for Tips I've learned over 10 years for maintainability of my code

Tips I've learned over 10 years for maintainability of my code

Igor T
・1 min read

I've been writing code for over 10 years now, and although I've been doing more management lately, at my peak I was able to write 500+ lines of well-performing code a day. Here are the principles that helped me with this:

  1. Don't over-generalize
  2. Don't optimize your code in advance
  3. Name and group everything that happens correctly
  4. Don't mix algorithms and other technologically complex pieces of code with business logic
  5. Don't use any advanced features of any language
  6. It is worth throwing all OOP out of your head
  7. Use as many asserts, logs and other methods to catch unplanned system state as early as possible
  8. Every extra line of code is evil
Every extra line of code is evil:) Wherever possible, you should not use someone else's code that you have not read and understood

Here I placed just names of my mistakes, but if you are interested here the full version with each point explanations

Discussion (4)

Collapse
tomaszs2 profile image
Tomasz Smykowski

Agree with everything except one point :) Points one and two are great. If it comes to frontend it is especially true. Frontend is easy with frameworks. And I notice people like to compensate it with adding a lots of unnecessary wiring. To look more pro. But it has the adverse effect.

Collapse
alainvanhout profile image
Alain Van Hout • Edited

Nice list. I'd say that advanced language features tend to fall under the category of 'clever' which in software development is just a synonym for 'bad'.

With regard to the original (Go4) design patterns, I've always understood the primary lesson there to favour composition over inheritance, which is in line with what you're saying but unfortunately not how a great many people interpret OOP.

Collapse
nyorja profile image
Rod Fetalvero

I agree on 2.

Collapse
eljayadobe profile image
Eljay-Adobe

Only two hard things in computer science:

  • naming things
  • cache invalidation
  • off by one errors

...oh, and...

  • exception handling
  • concurrency
  • asynchonicity
  • object lifetime management