Monday, December 11, 2006

object oriented dotNet apps

Bonjour... over the years there has been a lot of confusion and also misunderstanding of what is object-oriented programming. Many consultants and programmers claim to know object-oriented programming... but its so easy to get distracted. Here is a good anology of what it means in lay man's term:

Object -
Consider that a Car is an object. It has fields and properties, such as Color, Make, Model, Age, GasLevel, and so on. These are the data that describe the state of the object. A Car object might also expose several methods, such as Accelerate, ShiftGears, or Turn. The methods represent behaviors the object can execute. And events represent notifications. For example, a Car object might receive an EngineOverheating event from its Engine object, or it might raise a Crash event when interacting with a Tree object. See... that describes members, methods and events of an object.

Encapsulation -
Returning to the Car example. If a Car object interacts with a Driver object, the Car interface might consist of a GoForward method, a GoBackward method, and a Stop method. This is all the information that the Driver needs to interact with the Car. The Car might contain an Engine object, for example, but the Driver doesn’t need to know about the Engine object—all the Driver cares about is that the methods can be called and that they return the appropriate values. Thus, if one Engine object is exchanged for another, it makes no difference to the Driver as long as the interface continues to function correctly.

Polymorphism -
For example, a Driver object can interact with a Car object through the Car public interface. If another object, such as a Truck object or a SportsCar object, exposes the same public interface, the Driver object can interact with them without regard to the specific implementation of that interface.

Simple huh... its easier to understand this way.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home