Home > Microsoft .Net Development Tips > Visual Basic and Visual Basic .NET > The polymorphism debate, part 3
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

VISUAL BASIC AND VISUAL BASIC .NET

The polymorphism debate, part 3


William T
02.01.2004
Rating: -4.50- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Please let other users know how useful this tip is by rating it below. Do you have a tip or code of your own you'd like to share? Submit it here.


With regards to the tipThe polymorphism debate, I was the other developer member Eric was referring to. I submitted the tip Polymorphism is a must in VB.NET as a commentary on his first tip Polymorphism can lead to head scratching in VB.NET.

While we both agree that object-oriented design and practice must be implemented "...with careful planning and design in order not to lose focus." I dont agree with his sentence (and I am wide-open to any corrections or citicisms.) about the MyClass keyword "...getting rid of polymorphism" in my earlier codes.

My understanding of polymorhism is as follows:

  • Definition: A property of object oriented software by which an abstract operation may be performed in different ways in different classes.

  • Exists: When several classes, which each implement the operation, either have a common superclass in which the operation exists, or else implement an same common interface that contains the operation.

    In this case, as long as you can override the p1 method of the parent or base class, that method itself is polymorphic. As long as I can override or extend that method, without changing the method name of the class, polymorphism has taken place.

    I admit I was wrong not to stress on the fact that the error lies on the code-design issue as pointed out in the most recent tip on this subject,The polymorphism debate, part 2, and not a language handicap of VB.NET itself.

    We have to stress to young, budding, junior and even senior code builders, warriors, writers, authors that the quality of code itself lies in the code design, and not the language itself.

    By the above token, what I am trying to say is that OOP is just a feature (albeit a BIG feature) of a language, it doesnt necessarily mean that just because a language has OOP, any application or logic that is written in that particular language will have flawless codes.

    I am not a VB.NET Ppoponent ... I am a technology evangelist. I have worked with Java programmers that churned out low-quality-designed Java codes and I have also worked with legacy Basic and COBOL programmers that churned out good-quality codes. What is defined by quality, to me, is the maintainability of it.

    Please refer to this excellent Code Project article here about the wrong use of OOP.

    Taking a good look at Eric's first code base that was meant for demonstrative purpose, it is already poorly designed (please correct me if I am wrong) when:

    You design a base class that has methods (p2) calling an overridable method (p1) without defining whether the overridable p1 you are calling in p2 acutally belongs to the Base class or the Subclass p1. That is already a NO-NO in OOAD.

    However, Eric has already given the antidote and the preventive measures to take when designing in his intial article.

    The "MyClass" keyword of VB.NET is just a solution to the demonstrated codes that Eric had presented in that context. It is not meant to solve the problem of Circular Reference in OOP. But in all fairness, no keyword can.

    My tip, Polymorphism is a must in VB.NET, only serves as another preventive measure to be added on top of Eric's and to solve a similar problem should such a situation arises. You add the "MyClass" keyword to signify to the calling class that all references to p2 must call the Parent Class's method p1.

    Polymorphism still exists because you are allowing the Subclass to override or /and extend its methods. What you do within the overriden code shouldn't signify if that method is polymorphic or not ... i.e., if I didn't call MyBase.p2 in p1 of Child Class, does it mean that suddenly the Base Class p1 is now polymorphic?

    I thank Eric for his very constructive comments and his thoughts and more importantly, making us think, create and innovate. I think we both agree that just because we have plutonium on our backyard doesnt mean we should go create a nuclear bomb. It should all done very carefully and with proper design or we end up nuking ourselves via a stack overflow in the process. :)

    Rate this Tip
    To rate tips, you must be a member of SearchWinDevelopment.com.
    Register now to start rating these tips. Log in if you are already a member.




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



    RELATED CONTENT
    Visual Basic and Visual Basic .NET
    Compose XML more quickly using Visual Basic 9
    Virtualization keeps Legacy Apps alive
    VB 9 Anonymous Types help create flexible objects
    Visual Studio Team System Add-ins: Conchango Scrum for Team System and Scrum Dashboard
    Book Excerpt: Sams Teach Yourself Visual Basic 2008 in 24 Hours -- Complete Starter Kit
    Check out CodePlex for a ton of interesting .NET projects
    Book excerpt: Murach's VB 2008
    Book excerpt: Printing in Visual Basic 2005
    Visual Basic 2008 and closures
    WinForms development using SQL Server 2005 and Visual Basic 2005

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



  • Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts