aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S: code complexity and number of classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S: code complexity and number of classes" Watch "B&S: code complexity and number of classes" New topic
Author

B&S: code complexity and number of classes

Michael Cox
Greenhorn

Joined: Sep 04, 2008
Posts: 10
Hi All,

B&S version 2.1.1 says:

"Code complexity, including nesting depth, argument passing, and the number of classes and interfaces, should be reasonable"

I wondering what they mean by "reasonable" and if I have gone too far and will fail because of that:

Some stats on my completed assignment:

Number of classes/interfaces: 151 classes of which 28 interfaces
Average class source lines: 58 (max 334)
Average method source lines: 8 (max 88)
Total source lines of code: 6900
Total javadoc lines of code: 6523

Average number of arguments: 0.92 (max 7)
Average nesting depth: 0.51 (max 5)
Average cyclometric complexity: 1.51 (between 1 and 2.75 across packages)
Total cyclometric complexity: 1054 (between 8 and 125 across packages)
Coupling factor 4.48%

(stats from MetricsReloaded - but there are so many complexity measures - which one)

Size of choices document: 16 pages or 5500 words
Size of user guides: 32 pages
Size of javadoc: 579 pages (when converted to PDF)

Many thanks in advance for any thoughts and experiences.

Michael
Jevgeni Zhukov
Greenhorn

Joined: Aug 28, 2008
Posts: 18

I had URLyBird 1.2.1 assignment:
24 classes (incl. 3 interfaces, 2 enums)
76 lines of text in Choices.txt
80 lines of text in userguide.txt


SCJP<br />SCJD
Jo�o Batista
Ranch Hand

Joined: May 25, 2008
Posts: 40
Can't tell the exact numbers but:
Classes: Around 30 (including 5 interfaces and at least an enum), nearing 4k LOC
Choices: A page and a half, maybe less.. it was really small
Userguide: 2 HTML pages with nice formatting and full of images. Got really fancy on that one.
Jethro Borsje
Ranch Hand

Joined: Jul 22, 2008
Posts: 100
Originally posted by Michael Cox:
Hi All,

B&S version 2.1.1 says:

"Code complexity, including nesting depth, argument passing, and the number of classes and interfaces, should be reasonable"

I wondering what they mean by "reasonable" and if I have gone too far and will fail because of that:

Some stats on my completed assignment:

Number of classes/interfaces: 151 classes of which 28 interfaces
Average class source lines: 58 (max 334)
Average method source lines: 8 (max 88)
Total source lines of code: 6900
Total javadoc lines of code: 6523

Average number of arguments: 0.92 (max 7)
Average nesting depth: 0.51 (max 5)
Average cyclometric complexity: 1.51 (between 1 and 2.75 across packages)
Total cyclometric complexity: 1054 (between 8 and 125 across packages)
Coupling factor 4.48%

(stats from MetricsReloaded - but there are so many complexity measures - which one)

Size of choices document: 16 pages or 5500 words
Size of user guides: 32 pages
Size of javadoc: 579 pages (when converted to PDF)

Many thanks in advance for any thoughts and experiences.


Looking at these stats I think you went little overboard. You did you managed to get to 28 interfaces for example... Also I think your choices.txt is to big, it should not contain each and every minor decision you made.

I am currently working on my B&S assignment but I think I will come nowhere near these amounts.


SCJP, SCJD
Kah Tang
Ranch Hand

Joined: Sep 10, 2007
Posts: 58
I agree with Jethro that those are big numbers. Are you sure you need all those classes you created? Keep in mind that you're writing the application as if the psycho-maniac living next to you is going to support the application.
Michael Cox
Greenhorn

Joined: Sep 04, 2008
Posts: 10
Thanks for your thoughts guys.

Definitely going to try and trim the design choices.

And as for code:

Well I did go big time for a framework - used MVC and tried to work to interfaces always - hence the number of interfaces.

The GUI code in particular involved many classes - probably about 75% of the overall classes.

The number of classes doesn't include anonymous classes and in fact I generally avoid those like the plague and create inner classes instead. Reason being that I think they make for horrible looking code. That increase in the number of inner classes probably accounts for some of the big numbers.

I guess I was sort of hoping that my total lines of source would be ok even if the number of classes was large.

Maybe lines of source code is a better metric of how much I may have overcooked the goose.

Time to trim some of the fat perhaps unless someone says "don't worry I submitted 12000 lnes of code and did OK" :-)
Gilles Marceau
Ranch Hand

Joined: Feb 17, 2007
Posts: 78
I passed the SCJD last week, so i can give you my figures :

83 classes & interfaces, size = 284 Ko
choices.txt 48 Ko (around 18 pages)
userguide.html 20 Ko (no pictures here, around 6 pages)
Total archive size : 811 Ko

I think my projet is a bit big, but i meet the requirement concerning
the maximum size the deliverable should not exceed (1000 Ko, if i remenber
correctly).

hope this helps

Gilles
[ September 06, 2008: Message edited by: Gilles Marceau ]

SCJP 1.5<br />SCJD 1.6<br />SCBCD in progress...
Michael Cox
Greenhorn

Joined: Sep 04, 2008
Posts: 10
Phew.

After some time I am down from 150 classes and a 2.5Mb assignment jar file to..

75 classes and 780Kb assignment jar file.

For the record: in order of benefit...

  • Reducing the number and size of screenshot images and eliminating multiple copies e.g. in classes dir and source dir.
  • Reducing generated javadoc to protected only (but keeping private javadoc in the code)
  • Merging View and Controller components in the GUI and eliminating an MVC cluster for the configuration management.
  • Reducing the amount of object orientated "posturing" i.e. working to interfaces everywhere , having factories for everything. All the code changes were made with no reduction in functionality whatsoever - I only removed pattern-inspired "bloat".


  • Think I went a bit mad - the downside of having no deadline and wanting to do really well!

    Many thanks for all your comments above.

    Michael
    Jethro Borsje
    Ranch Hand

    Joined: Jul 22, 2008
    Posts: 100
    Good look on your submission!
    Adrian Engler
    Greenhorn

    Joined: Sep 18, 2006
    Posts: 29
    I had a similar number of classes (and also after reducing the code significantly). I found it was really strange to work without a deadline - if you have unlimited time and want to do it well, there is the danger that it will become more and more.


    SCJP 5.0 (93%), SCWCD (98%), SCJD (377/400), SCBCD (100%)
    Jethro Borsje
    Ranch Hand

    Joined: Jul 22, 2008
    Posts: 100
    These are my stats:
    Number of packages: 5
    Number of classes: 24
    Number of interfaces: 3
    Number of lines of code: 1723
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: B&S: code complexity and number of classes