upvote
> If you can't understand why the code is done in a certain way from reading it then the code is missing comments or needs to be refactored.

Code is never missing contexts. If what your code is doing is not obvious to the reader, it is bad code that needs to be fixed. Things like cryptic low-level expressions should be extracted to helper functions with descriptive names or even extracted into a class, and classes need to comply with the single responsibility principle.

reply
Ah the classic thinking that 'code documents itself'. It does not. Some devs are so full of themselves they think their code is so good that it is obvious what their intent was. It never is obvious, and just ends up as tech debt. Write comments.
reply
yeah that's how a simple algorithm that would fit on a napkin gets broken up into a soup of ravioli that I have no hope to understand. I often end up refactoring it into a simple function in a branch so I can figure out wtf is going on.
reply
> yeah that's how a simple algorithm that would fit on a napkin gets broken up into a soup of ravioli that I have no hope to understand.

No, not really. You get spaghetti code by being unable to refactor your code to follow inconsistent level of detail across calls. That's the textbook definition.

Once you start to follow basic code quality and software engineering principles, you'll notice right away that your code becomes both easier to understand and to test.

reply
My code is fine, thanks. It's other people's code that I have a problem reading.
reply
Codex barely writes any comments, while Claude makes a slop article for every one line commit. I’d enjoy something in the middle.
reply
Yes exactly. I don't like Codex not writing comments - and even proactively removing useful comments! There was some change in the last month that causes Claude to write crazy long comments. I routinely have to ask Claude to 'tighten' up the comments before the final commit.
reply
Try antigravity. I think it generally has the right level of comments.
reply