How were those past developers of this project so very wrong?
Something I touched on a little in "Pull Requests Welcome™" is how developers like to complain. I find a common target of complaint is old, or "legacy" code. Why was it done that way? What were they thinking? We're all guilty of it, myself included, but my suggestion is that we all assume a little more empathy for those that came before us.
Feb 15, 2020 · 5 min read
Developers like to complain. We'll complain about lack of documentation, lack of tests, choice of framework, choice of linter settings, and so on. My response to it? Pull requests welcome.
We probably don't know what pressures those people were under, what was being demanded of them, what political games were being played, what kind of tooling they had available to them, or even what was going on in their personal life at the time.
Just think about all the times you've read your own, old code and thought "what was I thinking?" It's probably because you've grown as a developer - something that's expected, almost required of us. So we can make a safe assumption that the original developer has also grown, at least some, and maybe they also would write the same code differently now.
Difference of context
Instead of thinking like this: "Well you shouldn't have done it like that!"— Colin Toh (@p0larBoy) May 11, 2020
Think like "OK, let's assume some clever people wrote
this. I wonder what the pressures were that
made them come out with that solution."
Code can always be written cleaner, written so it performs faster, written with stronger tests, written in a way that's more observable - that's why we try to not grow attached to our code babies and instead rewrite when necessary (and when the cost/benefits are right). But without having the full context past developers did we don't know if it could have been done better, at that time.
A different stand
Being critical is easy, trying to understand is much more difficult. Rather than ask "why was it done this [suboptimal] way?" let's all commit to being team players and ask "how can I help make it better?"