Home Categories Submit Republish Tools Links Credits Contact
Popular Articles
 
     
 
 Categories
 
 
Submit your articles online!

.NET:Solving The Multiple Inheritance Issue Under .NET Platform

By: Thomas Kaloyani

Published: September 1, 2007
Link To Article Link To Article  E-mail Article E-mail Article  Republish Article Republish Article
.NET platform does not support multiple inheritance. Do not confuse multilevel inheritance with multiple inheritance. With multiple inheritance we can have a subclass that inherits from two classes at the same time.

Let’s suppose we have an application that has a class Customers and another class Vendors. If you wanted to combine these two classes into one CustomerVendor class it would be a combination of Customers and Vendors just like the diagram below.

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

In the above diagram we see how the CustomerVendor class inherits from both of those classes.

Multiple inheritance is complex and can be dangerous. The advantages of code re-usage prevail over complexity is up to your choice.

Multiple inheritance is not supported by VB.NET or .Net platform. Instead of multiple inheritance we can use multiple interfaces to achieve similar effect to multiple inheritance.

In VB.NET all objects have a primary or native interface, which is composed of properties, events, methods or member variables declared using Public keyword. Objects can implement also secondary interfaces by using Implement keyword.

Sometimes it is helpful for an object to have more than one interface, allowing us to interact with the object in different ways. Inheritance allow us to create subclasses that are a specialized case of the base class.

Example

Sometimes we have a group of objects that are not the similar, but we want to handle them the same manner. We want all the objects to act as if they are the same, even though they are different.

We can have some different objects in an application, such as customer, product, invoice, etc. Each object would have a default interface appropriate to each individual object, and each of them is a different class. No natural inheritance is implied between these classes. Let’s suppose we want to print a document for each type of object. In this case we’d like to make them all act as printable object. To accomplish this we can define a generic interface that would enable generating a printed document. By implementing a common interface we are able to write a routine that accepts any object that implements a printed document.

To conclude, by implementing multiple interfaces in VB.NET, we can achieve a similar effect to that of multiple inheritance.

Thomas is an experienced Visual Basic developer, with expertise of 7+ years developing especially financial applications. His main IT skills are VB, SQL, Crystal Reports - should you need a Visual Basic developer for your projects feel free to contact Thomas through his personal website Kaloyani.com or through VBprofs.com - the newest Visual Basic and VB.NET resources portal.



Visitor Comments

Post Comment Post A Comment
What do you think about this article? Do you agree or disagree with it? Be the first to comment on this article, and share your thoughts with the world. No registration is required to post comments.

Article Icon Computer Programming - A Brief History
If a definition of a computer is that it is a piece of equipment that needs to follow various directions in order to carry out the tasks required of it, then the history of computers can be traced back to...
Article Icon Top 10 Elements Of Open Source Development
Open source development has undergone lot of changes to emerge as powerful in recent times. Today when software's are getting expensive consistently, open source techniques can eloquently help in making...
Article Icon The Usefulness Of Each IPhone Entertainment App
Apps with break through features like Audio/video playes, music players, and social media apps.
Article Icon Form Vs. Function? Which Is More Important In GUI Development?
During GUI training, students learn about graphical user interfaces. These are interfaces that allow users to interact with a computer in ways other than only typing and text.
Article Icon The Development Of IPhone Enterprise Apps
The Enterprise apps interact with the home server to get sensitive data of your customers.
Article Icon Alarm Clocks And Online Collaboration
Have you ever bought a piece of equipment that you thought would come in very handy only to leave it lying around for months because you could not figure out how to set it up? Or not set all the functions...
Article Icon IPhone Web Application Development
Since the creation of personal computers and the World Wide Web, technology has moved on to the creation of various computer and web applications that users can enjoy while using their personal computers or...
Article Icon Hire Android Developers
Google Android is a platform for professionals, offering a wide range of options and many opportunities for development of high quality Android applications. For the highly advanced and smart choices, the...
Article Icon Who Becomes An IPhone App Developer?
It's not a classic job title like fireman, president or teacher. Exactly who becomes an iPhone app developer, and what makes the job attractive to them? Read below to learn about the personality traits...
Article Icon Characteristics Of IPhone Application Developers
iPhone application developers share a common list of traits that serve them well in their chosen profession. Read below as you learn what makes these 'techies' so good at what they do, and then commission one


Print This Article Print This Article
Add To Favorites Add To Favorites
Cite This Article Cite This Article
 
 
Home | Categories | Submit | Republish | Tools | Links | Credits | Contact | Privacy Statement | Terms Of Use
Copyright © 2012 InfoServe Media, LLC (DBA PopularArticles.com). All rights reserved.