DEV Community

Discussion on: Should I break down my code if it'll only be used once?

Collapse
 
leoat12 profile image
Leonardo Teteo

I think you cannot be excessive either. I generally create methods based on action, if it is named "update" it means it will update something and everything related to update the entity will be there. Sometimes it is simple line, other it can span through 20~40 lines, depending on the business logic. Everything is related to an action, so I don't think it is necessary to break everything down.
The excess happened in some old code here sometimes, there are a method that calls a method, that calls a method, some of them are 3~4 lines of code! If you think it is more readable, I respectfully disagree. You have to jump around the code and get lost in the process.