How We Should Teach Our Children the Power of Object Oriented Programming with Only One Inheritance

By admin

Yea I got the same issue when a class implements 2 different interfaces and those 2 interfaces have the same property. Then one have to shadow the other.

I am just curious.

If we have

Class Rich
End Class
Class Man
End Class
Class Horny
End Class
It seems to make sense to

have Class HornyRichMen inherits Horny, Rich, and Men.

I suppose VB.net classes tend to be more flat in hierarchy than C++ code. Even then in C++ most function are virtuals and you rewrite the code in the derived class. Most feature of inheritance can be replaced with just owning.

So

Class HornyRichMen
Manness as Man
Hornyness as Horny
Wealth as Rich
End Class

Then you run into issue that HornyRichMen cannot be plugged into function that accept Man argument.

But that’s where interface iMan, iHorny, and iRich comes in.

Now Let’s go to further sample.

Say we have

Dim Women as Object

Now, HornyRichMen has a method, called knock up.

Say Bob as HornyRichMen

Now Class HornyRichMen will just need to re implement all their parent classes method the way God designed real HornyRichMen.


, , , , , , , , ,

categoriaGeneral commentoNo Comments dataMarch 2nd, 2011

About...

This author published 216 posts in this site.

Share

FacebookTwitterEmailWindows LiveTechnoratiDeliciousDiggStumbleponMyspaceLikedin

Leave a comment