The Pillars of Object Oriented Programming (POOP)

This post is based on Chapter 5 of Andrew Troelsen’s “Pro C# 2008 and the .Net Platform” availble from Apress.

These are of course Encaptulation, Inheritance and Polymorphism.

So we Encapsulate logic within object to allows us to do wonderful things like MyObject.GoAndDoSomethingComplicatedWithoutTellingMeAllTheBoringDetails();

We Inherit to promote code reuse – so we define common properties and functionality in a base class. Another form of code reuse is the “has-a” relationship (as opposed to the “is-a” we get from inheritance.

And finally, we Polymorph when we have a load of related objects and we want them to do something – each in their own specific way. One example that springs to mind is the ASP.NET webcontrols that are all asked to render themselves as the control tree structure is parsed during the page render process. Here, we do not care whether we are dealing with a RadioButton, a Label or indeed a GridView – we just know that they are all WebControls and that they contain and handle the Render(HtmlTextWriter writer); method.
The question is then of course – how do we know that…?


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: