What is encapsulation? - preCharge Forums
It shows that you are unregistered. Please register with us by clicking Here
preCharge Forums


Nav Green LeftNav Right
preCharge Forums > Website Design & Development > Programming > .NET » What is encapsulation?


Reply
Tcat Right
 
LinkBack Thread Tools Display Modes Tcat Right
Old 08-01-2006   #1 (permalink)
agaba175
Banned User
 
Join Date: Jul 2006
Location: India
Age: 29
Posts: 105
Default What is encapsulation?

What is encapsulation?
agaba175 is offline   Reply With Quote


Old 08-07-2006   #2 (permalink)
Francisjr
Member
 
Join Date: Jul 2006
Age: 28
Posts: 61
Default Re: What is encapsulation?

The most basic idea in OOP is that each object encapsulates some data and code. The object takes requests from other client objects, but does not expose its the details of its data or code to them. The object alone is responsible for its own state, exposing public messages for clients, and declaring private the ivars and methods that make up the implementation. The client depends on the (hopefully) simple public interface, and does not know about or depend on the details of the implementation.
For example, a HashTable object will take get() and set() requests from other
objects, but does not expose its internal hash table data structures or the code strategies that it uses. The theme here is one of separation -- trying to keep the complexity inside one object from interfering with another object. Or put another way, trying to keep the various objects as independent from each other as possible.
Each object provides some service or "interface" for the other objects. Ideally, the service is exposed in a way that is simple for the other objects to understand. The complexity of the implementation still exists, but it is isolated inside the one class. This works because for most problems there are all sorts of details of the implementation that the clients don't really care about -- how the hash buckets are arranged for example.. Inevitably, the interface that captures just the issues relevant to the client is much simpler than the full implementation.
Looking at a whole program, we have many objects, each exposing a simple
interface to the other objects and keeping the details of its own implementation hidden. With all the objects following this strategy, we get a divide-and-conquer solution to the whole program. Instead of a 1000 line program, we have a bunch of 200 line objects with minimal dependencies on each other. In this way, we escape the n^2 trap of writing and debugging large programs.
Francisjr is offline   Reply With Quote

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


footer left
All times are GMT. The time now is 06:51 AM.

DISCLAIMER: preCharge Risk Management is not responsible for any opinions, advice or comments expressed on the preCharge Community Forums.
preCharge® is a registered trademark of preCharge Risk Management | chargeback protection | Merchant Account Blog

Powered by vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC6

Money | Business Credit Card | Debt | Freelance | Mortgage Calculator

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49