Those cases are rare. Often the most basic solution is good enough.
If you have to write complex code, then you should write a comment (write the name of the algorithm for example).
Comment on Bill is a pro grammer
Vilian@lemmy.ca 11 months agoand if you need an unnecessarily complex ode for performance sake?
Those cases are rare. Often the most basic solution is good enough.
If you have to write complex code, then you should write a comment (write the name of the algorithm for example).
Rare?
Where do you guys work that all you do is write basic AI generatable code?
The only thing I can think is that you are a bunch of freelance devs who never have to maintain anything or add functionality to old code.
Either that or you are all new and are just full of theoretical bullshit that you read on the internet.
So you implement A* type of algorithms every day in your work?
Yes. I mean often enough that I wouldn’t call it rare.
You are a front-end js/ts devel, aren’t you? That makes sense. I can understand why you would have such a skewed view of programming. When everything you write is disposable and might be scrapped every 2 - 3 years, comments would seem like nonsense and a waste of time.
But that is definitely not everyone’s experience. More than half the code I have written has had a minimum 15 year life expectancy. Comments are essential to remember what I was doing in whatever random language I had to use at a given point. I might not comment on “x++;” but I sure as shit will on “x += (xDelta * yDelta + 31) / 32;” Actually, that’s not true, if the logic is complex enough for the rest of the code chunk, I might just comment on “x++;” to make it clear what x is in this case and why it needs to unconditionally be incremented here. Even if the reason seems ridiculously obvious right now. Because that shit might not be obvious at all in 10 years.
hstde@feddit.de 11 months ago
There’s a comment for you to explain the why.
Rule of thumb: code explains the how and what, comments explain the why.
philm@programming.dev 11 months ago
Yeah that’s a good summary