When should I break a function, break a class? What is a standard style of writing code?
There is no any specified rules for this. But line should be as low as possible. But you may follow the Role of 30. It is one of the good practice of writing code.
Rule of 30:
“Rule of 30” in Refactoring in Large Software Projects by Martin Lippert and Stephen Roock:
Methods should not have more than an average of 30 code lines.
A class should contain an average of less than 30 methods.
A package/library shouldn’t contain more than 30 classes.
Subsystems should avoid more than 30 packages.
A system more than 30 subsystems may create problem.
If an element consists of more than 30 subelements, it is highly probable that there is a serious problem.
You can get more details here
https://stackoverflow.com/questions/610588/when-should-i-break-a-function/66042052#66042052
It may help you to understand clearly.
Thank you
Comments
Post a Comment