DEV Community

Discussion on: Livable code, embrace the practical mess

Collapse
 
codevault profile image
Sergiu Mureşan

Great analogy!

If code is too clean it's really hard to keep it clean. To not get into that extreme I think you should take into consideration the amount of lines of code. A good refactor is one that makes the code readable and halves the original number of lines of code. (or whatever percentage works for your project, we just have a lot of duplicate code :P )

Collapse
 
jhotterbeekx profile image
John Hotterbeekx

While a lot of guides give you these guidelines, like the number of lines per code for a class, they should remain guidelines. Don't treat these guidelines as facts and treat each file in it's own way to maximize it's readability, not it's compatibility with clean code guidelines. So don't make splitting halve of the lines in you class a goal, make the goal to make it easier to read, maintain and extend. If that leads to moving more than halve the lines to a different class, great, if it doesn't, don't try to enforce it.