DEV Community

Discussion on: Design your code for readability

Collapse
 
ice_lenor profile image
Elena

Thank you Wajdi, nice to know you like the article!

Love your lambdas example :). I wonder if you tried to read your code some time later? What did you think of it?

40 000 lines is not a joke, unfortunately. :(

Regarding the tests: in my opinion they help a lot to understand the contract. But not the implementation. So sometimes they're not enough. For example, if I'm doing something for legal reasons, or if it's complex business logic, or it's a workaround, I always write a comment explaining that.
With only a test you can see the result, but don't know why it should be like this.

A docstring is sort of a comment as well, isn't it? Of course, it's also very helpful.

Ultimately, I try to look at the code as if I see it for the first time, and explain it to myself with comments.