-1

I am a noob to OO concepts. I have found some places,

Encapsulation is hiding objects from clients and calling them through methods.

MSDN says,

Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object.

I assume first expression explains the usage of encapsulation while latter defines encapsulation. Even this has been raised as a question before it was more specific to Java and I would prefer to see a usage example of this concept when it comes to Progess 4GL. I recently came to know about OO capability of Progress 4GL and below is a sample class that I found out.

CLASS [<package>.]<class-name>
     [INHERITS <super-type-name> ] 
   [IMPLEMENTS <interface-type-name>
             [,<interface-type-name>]…] 
   [ FINAL ]:

    [ <data member> …]
    [ <constructor> ]
    [ <method> … ]
    [ <destructor> ]

END [ CLASS ]. 

Examples related to Progress 4GL would be highly appreciated and there are already some good answers exist which explain Encapsulation in general.

Ravinath
  • 65
  • 2
  • 14
  • Can you show us some code to reproduce the issue? – gunr2171 May 21 '14 at 14:46
  • 2
    check this article: http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming) – w.b May 21 '14 at 14:46
  • Read the historical importance of encapsulation of wikipedia, if you understand the origin of the concept it might be easier to grasp. http://en.wikipedia.org/wiki/Encapsulation_(object-oriented_programming)#Historical_Importance – flindeberg May 21 '14 at 14:57
  • I would like see an example specific to Progress 4GL and this is not duplicated any more and it would be great if you could remove the duplicate flag @crashmstr & buttiful buttefly, Servy, abatishchev, nvoigt – Ravinath May 30 '15 at 12:48

2 Answers2

2

Encapsulation is hiding objects from clients and calling them through methods

This is not really full definition of Encapsulation. It is just one way of applying it. The definition of MSDN is more complete, though I think it should add data and operations on data are encapsulated in programming constructs like class and namespace.

I guess you did not get the idea, because, the first definition can be derived from the second, more complete one. Encapsulation means packing data, properties, methods operation on data etc. so that the internals of data are hidden from client, so client only operates on data through the exposed interface (this part is what the first definition says).

Rakib
  • 7,435
  • 7
  • 29
  • 45
0

The MSDN definition is more appropriate. The former is closer to the definition of abstraction.

However, the terms are obviously related, since it's easier to abstract ideas when they're encapsulated.

John C
  • 1,931
  • 1
  • 22
  • 34
  • IMO abstraction is not exactly that. It is more the concept of removing specific element and keeping only useful/generic properties of an object. Abstracting an object does not mean hiding it. (debatable) – Samy Arous May 21 '14 at 14:53
  • Like I said, closer. Abstraction is an idea, but what's described is one implementation (among many usually better ones) of that idea. – John C May 21 '14 at 14:56