Saturday, December 25, 2010

. NET: Solving the Multiple Inheritance Issue under NET platform.

. NET platform does not support multiple inheritance. Not to be confused with multi-level inheritance, multiple inheritance. With multiple inheritance we have a subclass inherits from two classes simultaneously.

Suppose we have an application that a class customers and suppliers has a different class. If you wanted to combine these two customer classes in a vendor class, it would be a combination of customers and vendors as well as the picture below.

Please copy thefollowing URL into your browser to the diagram: [http://www.vbprofs.com/images/Article] Images/ThomasArt1.gif

In the above chart, we see how the customer vendor class inherits from these classes.

Multiple inheritance is complex and can be dangerous. The benefits of re-use of code complexity to override your choice.

Multiple inheritance is not supported by VB.NET or. NET platform supports. Instead of multiple inheritance we can achieve multiple interfacessimilar effect to multiple inheritance.

In VB.NET all objects have a primary or native interface that declares the properties, events, methods or variables have member is joined with Public keyword.
Objects can implement also secondary interfaces by using Implement keyword.

Sometimes it is an object have more than one interface, so that we interact with the object helpful in different ways. Inheritance allows us to sub-classes that are a special case of creatingBase class.

Example

Sometimes we have a group of objects that do not like, but we want to deal with them the same way. We want to do all objects as if they are equal, although they are different.

We can have several different objects in an application, such as customer, product, invoice etc. Each object would be a standard interface appropriate to have every single object, and each of them is a different class. No natural heritage is between implicitthese classes.
Suppose we want to print a document for each type of object. In this case, we want to make them all look as printable object.
To achieve this we can define a generic interface that allows production would a printed document.
By implementing a common interface, we can create a routine that each object to write accepts a printed document implemented.

At the conclusion through the implementation of multiple interfaces in VB.NET, we can achieve a similar effectto the multiple inheritance.

Thanks To : !: Cheapest Designers Living Room Furniture !: Tables Living Room Sale !: Best Buy Lighting Living Room Furniture !8!# Lighthouse Wind Chimes Order Now !8!# Purchase Blankets Lilac



No comments:

Post a Comment