Do you want to sleep well at night?


Do you want to sleep well at night?

That was the question a senior engineer asked me in 2015.

I had sought his feedback on some elegant code I wrote. While I was sure the code covered the scenario; I could not prove it would cover all possible scenarios all the time. That was a grey area that no one could predict and the risk involved necessitated a judgement call.

That pithy statement has stuck with me ever since. Every time I have to choose between two paths, I tend towards the foolproof approach. I definitely would love to sleep all night and even if I don’t get a 1 am call, I wouldn’t want a colleague to lose sleep or get woken up because of code I wrote.

The challenge is letting go after writing ‘elegant’ but potentially troublesome code. Sometimes the safest code is also the simplest code; let go of the ego.

Do you want to sleep well at night?

4 thoughts on “Do you want to sleep well at night?

  1. depends: what do you call simpler code: One that follows the Domain Driven Design, abstracting the domain from infrastructure or one that follows the simple documented guide of a framework like spring / flask?

    Like

  2. There’s no such thing as perfect code and, even if there were, requirements change (usually as soon as the user sees it!)
    However, sleeping at night is more easily obtained by being unattached to the results of your actions. Care about the quality of your work. Do your best and then accept whatever happens and move on.
    Things will break, but you can face that most effectively when it occurs, not by worrying about it in advance (as opposed to planning) .

    Liked by 1 person

    1. Thank Joseph, you are right. Paying attention to quality and not being overly attached to code works wonders.

      Ultimately things will break but unknown unknowns should be due to new scenarios rather than developer choice of esoteric implementations that are ‘cool’.

      Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.