Getting into shape

 Last week I was teaching a VB.NET class at Interface, and a student in the class took my classic illustration of abstraction and polymorphism to the next level.  I always like using ‘shape’ as an abstract example, where ‘draw’ is an abstract method.  I ask the question “If you create a ‘shape’ with a ‘draw’ method… what will the shape look like?”  Of course, shape is too abstract to know the answer. 

When the example reached making shape an Interface, and implementing polymorphism through the draw method, one student decided to make a VB.NET project to prove it all.  He not only implemented the IShape Interface into things such as Circle, Triangle, and Square…  He implemented IShape in a Cadillac class too!  You have to see it to appreciate it. 

I wanted to give him credit for pushing his learning experience to another level.  His name is Geoff, and here is the download of his project.

Geoff will be reading this weblog, so if you download the project, please come back and provide comments about his creation.

1 Comment

  • I've always felt the best way to really understand something is to do it. You remember a lot more from hands-on experience then from anything else.



    I happened to have been working with GDI+ the week before attending Mike's class so when he started talking about the Shape class I thought I would test it out.



    I have since used the same approach for a reporting engine to display a few simple graphs: Bar Chart, Pie Chart, and I am working on the Area Chart. The statistics are first displayed in text form, and the user can select the type of graphical representation they would like. Using interfaces w/ polymorphism has made the project MUCH easier then what I was trying to do before the class.



    Thanks for the experience Mike, I've been busy re-writing a lot of my current projects to utilize the skills I learned while in your class.

Comments have been disabled for this content.