4 ms·
Five hours ago I was reviewing some failed tests in a PR. The affected code was probably 300 lines, total source for the project ~1200 lines. Reading the code,
by 0xbadcafebee 9mo ago
Five hours ago I was reviewing some failed tests in a PR. The affected code was probably 300 lines, total source for the project ~1200 lines. Reading the code, I couldn't figure out what the hell was going on... and I wrote all the code. Why would that be failing? This all looks totally fine. <changes some lines> There that should fix it! <runs test suite; 6 new broken tests> Fuck.
When you write code, your brain follows a logical series of steps to produce the code, based on a context you pre-loaded in your brain in order to be capable of writing it that way. The reader does not have that context pre-loaded in their brain; they have to reverse-engineer the context in order to understand the code, and that can be time-consuming, laborious, and (as in my case) erroneous.
- nly 9mo agoSounds like you were just reviewing bad code. The author should have provided context via comments and structured the code in a way that is easy to change and understand
- crazygringo 9mo agoExactly. A long time ago, I learned to write comments explaining all necessary context for my future self and for others -- exactly for this reason. Remember, you're not writing code just to execute. You're writing it to be read.
- h4kunamata 9mo agoI worked with people that defended the idea that code should not have comments, the code should self explain itself. I am not a developer and I completely disagree with that, the python scripts I wrote, Ansible playbook, they all have comments because 1 month down the road I no longer remember why I did what I did, was that a system limitation or software limitation or the easiest solution at the time???
- runeks 9mo ago> Sounds like you were just reviewing bad code. Software engineering in a nutshell