Hi very good question, but it will take forever to define these two..
You should go on wikipedia and them articles:
http://en.wikipedia.org/wiki/Encapsulation_(computer_science)
http://en.wikipedia.org/wiki/Abstraction_(programming)
Abstraction help encapsulation in some ways.
Encapsulation has two type of faces.
- Data abstraction
- Information hiding.
Data abstraction is a type seen from the outside.
Information hiding is a type seen from the inside.
Sometime encapsulation is used to mean information hiding only but I think the definition I gave is better because if you encapsulate something you get both an inside and an outside right.
Thats the main difference. I wont go in deep since you didn't read on them first.
Forexample when you abstract something, you can worry about that class only and not the other material. That is used in encapsulation.
Please take a look at the two above links
2006-06-13 03:44:34
·
answer #1
·
answered by ? 6
·
0⤊
1⤋
Encapsulation is hiding the internal implementation of a class. A client application only has access to the public members of a class. The protected and private members are off limits. This means that as long as the public interface remains the same, the internal implemenation can be changed without affecting the users.
Why do this? This is done because the first release may be "quick and dirty." After you have the interface and basic functionality out there, you can return to the interal implementation to make it more efficient, tighter, cleaner, etc.
While you may change the behavior of the class, you won't change the interface that the clients are using.
Abstraction is defining an interface without providing an implementation. This is useful when you want to provide a framework, but you need/expect each derived class to provide the implementation for the abstract interface.
Why define an interface without providing an implementation? The answer is too long to provide here. Look up polymorphism. That's where abstraction is used a lot.
2006-06-13 14:26:29
·
answer #2
·
answered by MarleyTheCat 3
·
0⤊
0⤋
"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."
Google forums explain it best.
2006-06-13 03:43:36
·
answer #3
·
answered by Sean I.T ? 7
·
0⤊
0⤋