• 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

public, protected, package

 
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering what to keep access levels of classes and methods? For example in my fbn.client package, do I need to make the FBNClient class package level or public? I was leaning toward the latter as then it cannot be accessed outside its package. Also server classes like IMPL's etc, do they need to be public? You see I am too used to using public all the time that i hate to think of package but that is the right way to go.
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also whats the point in having public methods, if the class itself is given package access?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that is a good question. I made sure that all my instance variable were private, and if I needed any of them that I would include a public method that would return the value.
As far as making the methods public, I think that package is good, but what if you want to extend some other new application and use the classes there. Or actually thinking about it my DataAccessFacade was part of my db package and not my client package, even though the client used it to pass calls to the data class. So if they were package then the client could never call them.
Mark
 
Kalichar Rangantittu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So do you think its a good thing to make classes package?
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nah, I like either public or private. I always think making something package visible only is limiting where the objects can be used.
Mark
 
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I want is to win the Lotto. Is that asking too much?
Of course not. Mark what a cool signature! I have not seen such a cool one, but seen a lot as follows.
XXXXXXXXXXXXXXX(My Good Name) THEN
SUN Certified Programmer For The Java 2 Platform
SUN Certified Web Component Developer For The Java 2 Platform
SUN Certified DeveloperFor The Java 2 Platform
SUN Certified Architect For The Java 2 Platform
BLAH,BLAH,BLAH,


A long tail after their name then their posting. I could not say anything even though I did not like it. Everybody knows certified people or who want to certify roam around JavaRanch. I know, they are certified and they have full right to express it as RESUME all the time. I am mouthy, it is really bad.
But I liked yours. GOOD LUCK! It was being unnoticed here. Just I wanted to draw the attention. I am sorry being off the track during public and private parade.
-Bal
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic