I might be in the minority, but I get more excited about the idea of maintaining/working on some creaky old legacy code base than I do about the idea of starting a new project from scratch.
- 0 Posts
- 9 Comments
I love doing that…
marlowe221@lemmy.worldto
Programmer Humor@lemmy.ml•Edge case? Corner case? Basket case.English
12·2 years agoI’ve definitely had the experience of something being broken in Prod… and no one can reproduce it in Dev.
Guess where we are fixing it!?
I think that, in many cases, “what” and “why” are very similar to each other or are closely related.
I’ve had an experience like this on more than one occasion - I come into an established code base for the first time. I’m working on a new feature/refactor/bug fix. I am reading through a function that is relevant to me, scratching my head a bit, and thinking “I think I see what this function is doing, but why did they do it such a screwy way?” Often there are no comments to give me any clues.
In the past, I have foolishly changed the code, thinking that I knew better… But what often happens is that I soon discover why my predecessor did something that looked so weird to me. They weren’t stupid - there was a reason for it! And then I end up putting it back…
Point being, in a situation like that the “what” and the “why” are going to have a lot of overlap. So, personally, I try to write comments that highlight assumptions that won’t be obvious from reading the code, external constraints that matter but don’t actually show up in the code, and so on.
I am far from perfect at it and I probably don’t write enough comments. But when I do, I try to write comments that will be reminders to myself, or fill in gaps in context for some hypothetical new person. I try to avoid comments that literally explain the code unless it’s particularly (and unavoidably) complex.
Glory to you and your house!
“Why” comments make more sense as application complexity grows.
You also have to consider interaction of the code with other external systems - sometimes external APIs force you to write code in ways you might not otherwise and it’s good to leave a trail for others on your team (and your future self…) about what was going on there.
marlowe221@lemmy.worldto
Programmer Humor@lemmy.ml•I redid the meme with what hurts meEnglish
4·2 years agoI know this may be an unpopular opinion on lemmy, which leans so heavily towards Linux and FOSS, and I’m a Linux user myself but….
I actually really like C# and .NET (the modern cross-platform version anyway).
And this is why mocks are bad…
Yep, I’ve had times where the debugger was hiding the race condition that was the actual cause of my problem.