• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

should classes/interfaces in submission all be public?

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic