[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1261
  • Last Modified:

abstraction, encapsulation, data hiding

as all of you know abstraction, encapsulation, data hiding are the +points of OOP languages compared to procedural languages.
Can you please tell me how these are interrelated, if possible with examples please so that I can understand clearly
0
ytgprasad
Asked:
ytgprasad
  • 5
  • 5
  • 5
  • +1
1 Solution
 
jasonclarkeCommented:
Thats an awful lot of explanation for 25 points.

Maybe you should look at some tutorials etc. on OOP.

Try http://www.cetus-links.org
0
 
nietodCommented:
That sounds a lot like a homework assignment.  We can't do an assignment for you.  That is grounds for removal from this site.
0
 
ytgprasadAuthor Commented:
to nietod: I am not doing any homework or any school assignment. I want to clarrify my doubts. If you still feel that I am doing home work then I cannot help. Infact I am more interested in the interrelation between these concepts.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ytgprasadAuthor Commented:
to nietod: I am not doing any homework or any school assignment. I want to clarrify my doubts. If you still feel that I am doing home work then I cannot help. Infact I am more interested in the interrelation between these concepts.
0
 
nietodCommented:
I was not trying to offend you, It just seemed (seems?) like an accademic question and we must make sure if it is or isn't.  (We can still help in an accademic question, but we can only provide _help_ not answers.)

>> abstraction, encapsulation, data hiding
>> are the +points of OOP languages
>> compared to procedural languages
Actually these are all good programming techniques in general and are not restricted to OOP.  A good OOP language makes it much easier to use these techniques and allows us to use them to a better extent, but the techniques transend the programming language.

In my "view" of things--i.e these are not necessarily the best definitions--abstraction occurs when you allow a portion of the program to "model" in the real world.  In OOP this most frequelty occurs when you allow a class to model or represent something.  i.e. if you create a class that records information about a car.  The abstraction is thinking about the class AS a car, rather than as a bunch of data and code in the program.

encapsulation is a process by which related data and the code that manipulates the data are grouped together and logically seperated from other code and data in the program.  In OOP this usualy involves creating a class.  The class stores the data and associates with the code (member functions) that are to work on or with the data.

data hiding is a process by which data that is used by one portion of the program is "hiden" from other portions.  By hiding the data you insure that other portios of the program are not dependant on this data.  This might allow you to change the implimentation of the portions that do use the data (perhaps removing this hidden data, or changing its nature)  without fear that the other portios of the program will suffer.  In OOP class data members--especially private and to some extent protected data member--are hidden.  They can be manipulated only by select portions of the program--the class's member functions, not by the entire program.  Thus you can change the data members in the class and you will only have to change the code inside the class's member functions.  No code outside the class's member functions even needs to be considered for change.
0
 
ytgprasadAuthor Commented:
to nietod : If you do not mind. I have a question regarding data hiding. Can you please visit this site http://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=10292868  and put your comments there regarding data hiding. That question also I posted.
0
 
yonatCommented:
I think about this a little differently: Data hiding is a technique to achieve encapsulation, encapsulation is a technique to achieve abstraction.

Abstraction does not necessarily relate to the "real world". Abstraction is when you treat something compex using a simpler model, and that model's behavior is accurate enough for your needs. The complex thing does not have to be in the "real world" - it can be some part of the program.
0
 
nietodCommented:
Yonat, I definitely don't wish to debate this stuff with you of all people, but...

>> Data hiding is a technique to achieve encapsulation
Can't you have encapsulation without data hiding?  I.e. doesn't

class Point
{
public:
    int X;
    int Y;
    void Set(int x,int y)
    {
        X = x;
        Y = y;
    };
};

perform encapsulation without perform data hiding?

I think of encapsulation as the process of grouping together data and code that works together and isolating it (to some extent) from other data and code in the program.   Data hidding seems-to me-to be the encapsulation to a high degree.  i.e the data can only be accessed by the code it is encapsulated with.

On abstraction, yes I agree totally.  The important point is that the abstraction "models" something else, something simpler.
0
 
yonatCommented:
> Yonat, I definitely don't wish to debate this stuff with you of all people

So you'd be glad to know that I think we agree!

I meant to say that data hiding is *a* technique to achieve encapsulation, not the only technique to achieve encapsulation. (Likewise, that encapsulation is *a* technique to achieve abstraction.)
0
 
nietodCommented:
I see.  Yes, that makes a lot of sense.  
0
 
ytgprasadAuthor Commented:
Yonat answer relating the concepts, I liked. If it is possible to give points to more than one person let me know. I would like to give some points to Netoid also.
0
 
yonatCommented:
Hmmm, I thought I added a comment, not locked the question...  Sorry for that everyone.
0
 
yonatCommented:
Oh, and you can post a new "dummy" question just for nietod to award him points.
0
 
ytgprasadAuthor Commented:
that is cheating, forget it
0
 
jasonclarkeCommented:
> give some points to Netoid

sounds like somebody has just invented a cybernetic version of nietod :)
0
 
yonatCommented:
I don't think it is cheating - you title the question "Ponits for nietod" so it is clear what you are doing. It is a common practice here in EE. (I even remember linda suggesting it once?)
0
 
nietodCommented:
Yonat,
>> Hmmm, I thought I added a comment,
>> not locked the question...
You did.  There is a new feature by which a comment may be accepted as an answer by the client.  It avoids the delay where a client has to request an expert to make a "dummy" answer.  However, it can at times make an expert look "greedy", like this.  Hopefully there wll be a different message for it in the next version.

>> that is cheating, forget it
Its not cheating, its a very common and accepted practice.  The only issue is whethor or not you have the points and/or want to spend them.

>> (I even remember linda suggesting it once?)
Linda is the head of customer service (she WAS customer service just a few weeks ago) and yes she has suggested it numerious times as do the rest of customer service.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 5
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now