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

Clean code of a guide, not a requirement.

Eg. I like paragraphed comments, because you know what the next 5 lines will do and you can quickly skip to the part you need.

It's not always possible to have a method with only 5 lines. There are use-cases where you want a big method doing a lot of things together, because it's complex.

Eg. For a government project i needed to connect to the internal network for executing certain requests and all that logic was in one HttpProxyClass, shared between the api + service/deamon




If those 5 lines do so much that you can't scan it quickly, why is it not in a function? I don't understand, why so many people here have a hard time of understanding this here on HN. You can't trust that comment, you don't know if its outdated or not.

Update: I noticed you updated your comment.

So my reaction to your addition is that a class can always be abstracted to higher level. It will probably do to much at this point.


I added the example of what i kept together, because that complex class was the junction class of 4 interfaces for server/client + receive/send.

The logic was much simpler to scan/change if you comprehend everything it does. Instead of only partially by abstraction. The use case that one thing was called for one-use case wasn't applicable.

I like clean code and apply it a lot. But it's not applicable for everything. I think you just didn't encounter the more advanced cases yet where it isn't, since they are not that frequent.

The spirit of clean code is to make readable code. Not the reality is that you have to adjust to the situation. They're is code were comments make sense. Comments can give context and intent ( look at code of sqlite for example).




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

Search: