Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

Data Abstrcation vs Encapsulation

Thread view: 
amanda - 07 Nov 2006 17:36 GMT
If someone asks me what Encapsulation is, how to I explain it? How
about Data Abstraction? I read a lot online but I want a very effective
answer to give.
richardsosborn@gmail.com - 07 Nov 2006 19:11 GMT
> If someone asks me what Encapsulation is, how to I explain it? How
> about Data Abstraction? I read a lot online but I want a very effective
> answer to give.

I'm not sure how much this will make sense.  Encapsulation is "hiding"
data within an appropriate wrapper.  This is what the Java Beans
specification was based on.
You have hidden members (class variables) and public accessors (methods
which
modify them).  Once you have data you wish to protect access to, you
"encapsulate"
it in a proper bean or class.  This is in place of simply dropping it
in a class and accessing
it however you like.  It makes data more thread safe, I'm sure, among
other things.

Abstraction is grouping like things together.  Often this is moving
frequently re-used
methods to a common "base class".  For instance, you have functions you
keep using
over and over in a group of database classes.  You might move them into
a top level,
"base class", you inherit.  This keeps you from writing them over and
over again.  Also
there's one place you change things in them.

I guess an example might be adding furniture to houses on a city block.
Do you place the
furniture within new houses and control access within them?  Or do you
add one house that  will showcase frequently-used items?
Manish Pandit - 07 Nov 2006 19:16 GMT
> If someone asks me what Encapsulation is, how to I explain it? How
> about Data Abstraction? I read a lot online but I want a very effective
> answer to give.

Encapsulation is combining the data, and the operations that work on
that data in a single unit.

Data Abstraction is being able to group smaller units of data into a
larger, logical unit that can be operated without the knowledge of
underlying components. For example, abstracting a Person data structure
out of 3 strings representing first, last, middle names, and an integer
representing age.

-cheers,
Manish
RedGrittyBrick - 07 Nov 2006 22:39 GMT
> If someone asks me what Encapsulation is, how to I explain it?

Wikipedia has some useful definitions of these and related concepts.

http://en.wikipedia.org/wiki/Information_hiding

> How
> about Data Abstraction?

http://en.wikipedia.org/wiki/Data_abstraction
amanda - 07 Nov 2006 23:43 GMT
Thank you all.

> If someone asks me what Encapsulation is, how to I explain it? How
> about Data Abstraction? I read a lot online but I want a very effective
> answer to give.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.