Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: What do you consider to be “Clean Code”?
1 point by ludovicianul on May 17, 2023 | hide | past | favorite | 3 comments
I'm really curious on different viewpoints for what you consider "Clean Code". Not clever code, but code that you can decently maintain, extend and understand.

(I'm not referring to the concepts that Robert C.Martin/Uncle Bob is preaching - although a significant category of people will consider that to be clean code - but rather in general - couldn't find a better naming)



- there's unit tests

- there's integration tests

- you can run the code locally and it works

- you can send data you control to the system

- you can check what the system responds with

- you can do all of the above in debug mode and breakpoints actually work

- the external dependencies are optional or you can control them too on dev environment without too much hassle

If I have all of that - maintenance will be easy, SOLID or no SOLID, functional or OOP or whatever.


My only requirements for "clean code" are the following:

- readable (use self-describing functions, names, etc; consistent spacing...)

- as little repetition as possible

- as efficient (or "clever") as can be, while not sacrificing the first two bullets

-- caveat to the last bullet: using "extra-clever" techniques is acceptable IFF, you very clearly document (in comments, code commits, etc) not only what the code is doing, but why you're doing it that way


In a functional sense, clean code is something you can return to in 6+ months and quickly understand the flow. Ideally, it's code that somebody else can look at and quickly understand the flow. Lack of cruft, clear naming conventions, yeah, but the logic has to be obvious, too.




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

Search: