Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

should classes/interfaces in submission all be public?

 
Grary Stimon
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I've been package-defaulting class and interface access wherever I can in my SCJD code. Did anybody read their instructions to suggest that all classes/interfaces should be public?

Thanks for any comment.

Grary
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Grary Stimon wrote:I've been package-defaulting class and interface access wherever I can in my SCJD code.

I did that too (all classes in the gui-package for example are package-private) and I passed, so don't think that's a problem.

Kind regards,
Roel
 
Grary Stimon
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel. Yeah, that's consistent with best practices a la Joshua Bloch. As you may or may not recall, Andrew left a lot of the classes in his example code public, so I just wanted to wave my hand.

Grary
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Grary,

Another useful tip to improve your code: I let PMD check the sources that I submitted (I did it afterwards, because I didn't know its existance) and it found approximately 250 violations (although i thought my code was just fine). But i didn't agree with all the violations (like the one that says you should only have 1 return statement in a method). But it is certainly worth your while. And it has also various plugins for IDE, so if you use it through an IDE you can indicate which rules must be checked and about which you don't care.

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic