Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm glad he brings up the much-maligned Singleton pattern as an object for debate - or beauty being in the eye of the beholder. "Clean" to me involves a range of classes and singletons (or better, all static code) in as close an approximation to use as they're a actually used in the final code. If something happens once only in your code, it's dumb to make it a class instance. If it happens twice but you know you will never need it again, same. If it happens repeatedly, refactor.

Clean code can be repetitive or concise. Readability is important, but only part of cleanliness. When you look at bad or dirty code you can tell immediately, because the logic is loose; it seems to try to handle edge cases at the end of a logic block, or catch errors that lead you to wonder why should this code ever encounter that error if the other code it's referring to is stable? Clean code displays confidence in knowing that edge cases are managed before they get to user functions.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: