Object-Oriented Programming - Part 1
Written by: Doug Jenkinson
Article
OOP has had a large resurgence lately, especially with the plethora of JavaScript libraries and frameworks to aid in AJAX development and with the .Net framework.
.Net is built around the ideas of objects and inheritance. For example, creating a custom control must inherit from the base control class, as do the familiar controls used in development such as labels and textboxes. JavaScript provides inheritance through the prototype property of every base object.
The idea is quite powerful: that each object is derived from another object, and inherits all its parents’ properties, methods, and events. These properties, methods, and events can then be overloaded to customize the functionality of the child.
In JavaScript, the notation known as JSON simply makes objects easy to write since objects described in JSON can be evaluated with the eval() function. However, I have yet to determine if objects created with JSON are inheritable. While using the eval() can be dangerous, it is a method currently being explored as an alternative to XML for use in asynchronous transmission of data.
With .Net, OOP and inheritance make the creation of new controls quite easy, especially when compared with previous releases of Microsoft's development tools. And while I do speak a lot of OOP being used in .Net for the modification of controls that is by no means its limit. A developer could create a new type of exception to trap in the event a particular error occurs.
This programming paradigm has become much more prevalent, often without a developer realizing they are practicing it. Once a developer wraps his head around just how powerful and easy OOP can be, it is doubtful that their code will be same. We've already seen some amazing code written to do some amazing things as part of this Web2.0 bubble and can only expect better as other catch on. Next week, I'll post a simple sample of OOP with inheritance in JavaScript.
Revisions
- v1.0 (3 Mar 2006) - Article published.

