Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Encapsulation, Abstraction, Polymorphism & Inheritance

Status
Not open for further replies.

pmcdaniel

Programmer
Feb 9, 2007
127
US
I dont' quite understand the below:
1.) Encapsulation
2.) Abstraction
3.) Polymorphism
4.) Inheritance

I've probably used/created these before in my VB 6 experience (My company does not have .net) but I don't quite understand what each means so I'd like to give some examples of what I've done and maybe someone can explain if/where I've accomplished any of the above.

I created a DLL called AddressInfo.dll which accesses a DB2 table to provide address information. This DLL is used on several machines.

There is one particular parameter which dictates what address is retrieved but over time it was decided we would need several types of addresses at the same time so I've created a couple classes from this dll called:
clsClientAddressInfo
clsExecuticeAddressInfo
clsCustomerAddressInfo

I also have a class to concatinate some of the address information called clsAddressInfo. It uses a function called BuildAddressInfo. I guess I could have done this with the DLL but at the time I created it, it was not required and I cannot just go and change the DLL. In this class I might build the clsClientAddressInfo.Address by concatinating BuildAddressInfo.Address1 & ", " & BuildAddressInfo.Address2 & ", " BuildAddressInfo.CityStateZip.

Thanks for your help and whatever I have not done can you please explain using what I've already done to accomplish all four of the above?
 
Of the 4, I'd say you've acheieved Encapsulation. This is basically 'information hiding' i.e not all of the methods/functions of your AddressInfo class are visible to all and sundry (it has some internal methods etc. that are declared as private I am assuming).

The purist's uses of Abstraction, Polymorphism and Inheritance within VB6 are limited as it's not a true object oriented langauge. It supports a version of Interface Inheritance (using the Implements keyword) but not Implementation Inheritance, it supports a form of Polymorphism through the aforementioned Implementing Interfacesand there is no Overloading so it doesn't support a huge part of Ad-Hoc Polymorphism.

Hope this helps

HarleyQuinn
---------------------------------
Black coat, white shoes, black hat, cadillac. The boy's a timebomb!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
Posted a bit quickly there, I was meant to finish by saying that even though you've probably only got one of the four, I wouldn't be too worried about not using the others if you don't fully understand them (and VB's limitations using them).

HarleyQuinn
---------------------------------
Black coat, white shoes, black hat, cadillac. The boy's a timebomb!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top