Re: understanding of data abstraction, information hiding and encapsulation
subramanian100in@yahoo.com, India wrote:
Is my following understanding correct ?
Data abstraction means providing the interface - that is, the set of
functions that can be called by the user of a class.
Information hiding means mentioning the class members(functions,
typedefs, data) under the access control labels : public, protected,
private.
Encapsulation means providing the implementation of class member
functions and the implementation is hidden except for the inline
functions which can be present inside the class definition or the
header file which are visible to the user of a class.
Encapsulation means that the state of an object can be manipulated by client
code only going through the public accessor methods. It is unrelated to
function implementation being inline or published in a header file.
Templated code usually goes into header files (since most compilers do not
support the export keyword). That does not break encapsulation at all.
Headers are meant for the compiler to read and are no substitute for
documentation. A programmer relying, e.g., on a sort function being stable
(which information may have been obtained by looking at the source and
discovering that heap sort is used) when the function is not documented as
being stable is in very deep waters.
Kindly correct me if my understanding is wrong. Wherever I have gone
wrong, please provide an example C++ class so that I can understand.
class Window {
int lower_x, lower_x, upper_x, upper_y;
// ...
public:
move ( int right, int up ) {
upper_x += right;
lower_x += right;
upper_y += up;
lower_y += up;
// some more
}
// ...
};
This class provides encapsulation since you cannot access its internals from
the outside directly.
Also, does the process identification of class,
Huh? never heard of that.
its member functions and data members, class objects, fall under
data abstraction?
Have you tried looking up a definition of data abstraction? Do those terms
match?
If not, what is it called.
I guess, it's called, in turn, "process information", "member
functions", "data members", and "class objects".
Why do you have a need for a term that is less specific? Only if we know the
purpose, we can suggest an appropriate word. Otherwise, I would suggests
the term "something".
Best
Kai-Uwe Bux