• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Class access levels

 
Paul Tongyoo
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again- now i'm confused on class access levels and I am forced to bring up this question because of my limited developer experience in the field...
Is it correct design to have the majority of classes in our system to have default access? Other than the classes that are necessary to connect one package to anther, most of my classes are just coupled to other classes within their respective package. This seems normal, but i just wanted to bring my question up because I noticed that javadoc doesn't produce docs for non-public classes and it felt odd to not have javadocs for my classes. Furthermore, the specs explicitly state that all classes must be javadoc'd.

Thanks in advance,
Paul
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
It can be correct to do that.
As a developer you should be looking at your classes, and working out which other classes need (or might need in the future) access to the class you are working on. Depending on your answer, you will find the correct access to use. I had quite a few classes with only package level access in my submission. This applies especially when you have a Fa�ade or a Factory - you really don't want outside classes calling the classes used by your Fa�ade or Factory, so it makes sense to limit the access levels of those classes.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic