mardi 13 avril 2021

On premature optimisation



Dev: this code is more optimal, i.e. better

Senior dev: most performance problems appear where we don't expect them, let's wait and measure

Senior dev: Besides most code optimizes one thing, it can be CPU-time, but also readability (i.e. developer time), but rarely more one thing. If we have to choose, which is the best optimisation in this case?


Dev: we need to optimise before it is too late

Senior dev: most perf problems I've had to deal with, were very simple to solve. Just limit the number of round-trips to the db, if not possible parallelize, if not possible maintain a read-model. Let's wait and measure.


Dev: but some problems require a completely different paradigm

Senior dev: True, and most often the business never scales that much. Let's wait (building a working system), validating that we actually have that problem! And read up on the CALM theorem, CRDT's*, CQRS etc


PS: Both devs are me. Just separated by two decades of experience 

* CRDT is a basically a data-structure that allows parallel writes