Encapsulation - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.


[b][red]This message was edited by LaurenH at 2004-3-3 23:45:32[/red][/b][hr]
Hello all,

With Regards to Encapsulation:
I understand is as basically - a class is an example of encapsulation.

I found a defintion on codepedia for encapsulation:
"Encapsulation states that we use methods to manipulate the classes properties and hade the properties them selfs." - http://www.codepedia.com/1/CustomCollections

The example used a class with its variables/properties defined as private and the methods as public.

If a class has its variables/properties declared as public does it still adhere to encapsulation?


  • Anthony@SFCAnthony@SFC Posts: 11Member

    Sounds like a reasonable definition of encapsulation. In my book using public variables does break this "law".

    Someone once posed this question to me:-

    "In what situation would you want class variables to be public?"

    I couldn't think of a situation. Can anyone else ?

Sign In or Register to comment.