• 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

private confusion

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had in my abstract class these data fields which I wanted to be inherited by my classes "Video" etc.
Then Marilyn asked:

I understand that private data fields are good for encapsulation. But you cannot inherit these. So why or how should I make my abstract class data fields private - or is it a "true question", meaning I should consciously choose to obliterate private (because, I admit, I forgot to make other data fields private in my inheriting classes).
Another thought:
I could give every of my classes its own "private String ..."
but this is more writing effort, and I thought
it might be of the "isn't there any room for
optimization" category if I save the writing.
But maybe there is a good reason to do this which is unclear to me so far?
Any disfogging highly encouraged,
Juliane
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Juliane, if you really need to have attributes like that, then they should be private to protect them from outside interference and you should provide some getXXX() accessor methods. How do you intend to set the values?
But have you seen this?
-Barry
 
juliane gross
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you, Barry.
I had seen that conversation (your link), but there are passages when I wish English would be my mother language, with all those subtleties..
Enough whining, I wait for my next nitpick and try again (you gave me an idea though, in your answer.. )

Juliane
 
whippersnapper
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by juliane gross:
but there are passages when I wish English would be my mother language, with all those subtleties..


We can give hints about the hints, if there's something that's particularly confusing. Just point out the parts that don't make sense.
It's fun to be a little bit sly and see how much you can say without giving too much away, but the idea is certainly not to further confuse someone.
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Matola:
but the idea is certainly not to further confuse someone.



Says who??
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic