• Post Reply Bookmark Topic Watch Topic
  • New Topic

Data abstraction vs Data Encapsulation  RSS feed

 
psarora -
Greenhorn
Posts: 1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can some on please define the terms clearly and provide the differences.

I am so very confused with these terms.

Cheers
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstraction is about leaving out details that don't matter in the current conversation so you can focus on other details that do matter. For example a method that takes a List parameter cares about the behavior that is promised by the List interface, but doesn't care whether it's an ArrayList or LinkedList or some other implementation. So we call List an abstraction and ArrayList a concrete example. Or I might say I have a program that is a socket server without going into all the details of ports, socket objects, IO exceptions, message payloads and so on.

What matters and what you can leave out depends on the conversation and the audience. If I explain my program to somebody who must write their first socket program as a client to my server, I might give them many more details.

Encapsulation has about as many definitions as there are OO programmers. I'd say it's some mix of bringing together related code and data and hiding information about the details. Some of the big names in the business have said that encapsulation == information hiding, while others point out that not all information hiding leads to good encapsulation and not all encapsulation leads to good information hiding.

Any of that help? Raise new questions?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgot to say 1) Welcome to the ranch! 2) The sheriffs will come around and remind you that your name should be a credible first and last name. 3) The OO, UML, etc. forum down the page talks about this kind of stuff all the time.

Enjoy your time here!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!