Hacker News new | ask | show | jobs
by vetler 3544 days ago
How to create readable code that explains itself should have more focus. It's not just about naming classes, methods and variables, but also about structuring your code. It's quite possible to create a method with the perfect name that is over nine thousand lines long and difficult to understand.

This can be very subjective, but code complexity metrics can help identify problem areas. I find that areas with high complexity often benefit from refactoring into smaller pieces making it more readable and self explanatory.

If you can't structure your code to explain itself, perhaps commenting isn't such a bad idea, at least it would be a record of your thoughts at the time, until someone else comes a long and hopefully cleans it up.

1 comments

Just to echo what has already been brought up here, sometimes it's not the what that is important, but the why. Reading the code is unlikely to explain the why for quite a few complex things.