Lessons learned


This is just a collection of random thoughts that I want myself to remember about software development

All if and else if’s need default case else.

When doing some checks on data there should always be default case for something thats not handled and either throw error or log it as error or unhandled case. This is where bugs hide.

Always reset variables assigned to this in class

When using classes always reset variables that are assigned to this context in class.

When refactoring old code prepare comprehensive testing plan

When refactoring large parts of old code always create comprehensive testing plan or better yet automated tests

When doing large developments that take multiple days test frequently

In Javascript async functions always return <Promise>. Call them with await.

Easy to miss and can cause bugs. <Promise> is always true.

Deploy to production often

Don’t develop for days and then deploy to production. Deploy daily, deploy small changes.

Break down changes to very small bits and deploy them

The smaller the deployment the easier and faster it is to find bug. Also much easier to debug when you know exactly what has changed.

When refactoring old code to add new features make sure old works before adding new features

When doing large refactorings to add new functionality then first deploy changes without new features but with only changes that make it possible to add new features and that keep old features working. When you are sure that old features are still working without regression then add new features.

Nothing worse then debugging in production

Add as much logging as possible. Log all edge cases, everything that should happen. Log all else’s in if-s that are not expected.

if adding check if (value.value) then log the case where it fails. If this fails in production with some production data then you don’t want to be debugging it live to find out how it fails.

Logs should be easily accessable, filterable and relative

No point in logging when you can’t quickly query it and find out whats the issue.


Leave a Reply

Your email address will not be published. Required fields are marked *