|
-
Jan 18th, 2007, 07:27 PM
#1
Thread Starter
Hyperactive Member
Just Seeing If I Have This Right
Hey everyone. I just want to see if I have my OOP concepts right or not. If I'm wrong about any or all of them, which I'm pretty sure I have one or more of them that I need to go over a few more times, please let me know and correct me.
Let's see, first there's encapsulation. The process of "data hiding." This is controlled with access modifiers (public, private, and protected).
Inheritance is the process of deriving a class from a base class. The base class usually contains very generic data that can be used in more abstract and specific derived classes. Any private members in the base class can be used in the derived class.
Polymorphism, I think, is where a derived class can also be a type of any of its base classes because it works like a tree. A derived class of Bear is derived from Animal hence Bear can be a Bear or an Animal type.
Please let me know if I'm missing something or are off track on anything. Thanks a bunch.
-
Jan 18th, 2007, 07:35 PM
#2
Fanatic Member
Re: Just Seeing If I Have This Right
Poly. Agree.
Inheritance. Agree.
Encapsulation, while data hiding is a use, to me this seems off. When I think of encapsulation, its more of a saying portable. Meaning if I have encapsulated, that I should be able to port it as a whole somewhere else without any added stuff. Ie. If I write a Database module to handle my I/O stuff and it constantlly refers to a connection string located in the Global module of my application, I have failed to encapsulate it. If I instead passed this connection string to my module through the use of properties to be stored, then it is encapsulated.
-
Jan 19th, 2007, 05:02 AM
#3
Re: Just Seeing If I Have This Right
Derived classes can't access private members of their bases, only protected ones.
Encapsulation, as Bilbo said, is about the independence of the class. It should be a drop-in black box for a specific purpose, with no "upward" dependencies, i.e. it should not depend in any way on classes that use it, only on classes it uses itself.
The second part of encapsulation is the data hiding part, where the class does not allow anything else to access it except through the well-defined public interface. This allows the class to keep its implementation independent of the user.
Polymorphism is about treating objects of different classes all the same as a common base.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|