I have to give a general note to some huge Java project for which I have but little visibility and I was wondering if there were any guidelines for determining:
I should note that this question is only dealing with volumetry. I have a bunch of reports from quality tools (checkstyle, jdepend, cpd, pmd, ncss) that give me more vision about code redundancy, classes usage, bugs, etc.
There is no limit in the specification, so you can put classes into the package until hitting a technical limitation. If not hitting a limit at the file system or archive format, the runtime implementation likely uses arrays or collections to hold the classes, which limits the number to something close to 2³¹.
A single Java program can contain more than one class and there are no restrictions on the number of classes that can be present in one Java program. But each Java program should have one class declared as public to make it accessible for classes in a different package.
a) Methods should not have more than an average of 30 code lines (not counting line spaces and comments). b) A class should contain an average of less than 30 methods, resulting in up to 900 lines of code.
As mentioned the above, there is no limit on "lines of code” per class in java, we can probably use 200 lines as a good guideline and not exceed 500 lines per class.
Steve McConnell in his book Code Complete recommends about 7 methods per class and no more lines in a method then can be viewed in a single screen without scrolling.
I'm not sure about classes per package.
I would highly recommend reading Code Complete for more information on such topics.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With