Hacker News new | past | comments | ask | show | jobs | submit login

I agree. I really hate having to jump all over a file (or multiple files!) for something that could fit into a single page of linear code.



Someone smart said, "When you've lost something, and finally find it, don't put it there again. Instead put it the first place you looked."

I think that applies to code. When I read something I wrote, if I'm annoyed at how it reads, I try to refactor it to be what I wanted to read, and remember to do it that way in the future.

But sometimes what the reader wants is too much work for the writer, so I don't push that effort beyond what it's worth.


There’s a whole style of coding dedicated to that very notion. It’s called test driven development.


I don’t agree that’s what TDD does. You spent inordinate amounts thinking about how you should want it to be, when you could just write it, find where and what about it you dislike, write it again and have actual good code. Also called WET. You spend less time with better results that way and you gain what OP was talking about in the process.


I agree too. Another example: I find early returns in functions easier to read than “else” with one “return” at the end. Basically vertically linear code as opposed to unnecessary branches and too much indentation, keeping the code slimmer is healthier!


It's also a naming issue. A good name means I don't have to jump.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: