In real life, everything around us has properties and methods, although we generally don't think about life in these terms. For example, a Pencil has a color, a length, a lead quality (“bring your #2 pencils”) ... and it also has methods, or things it can do like Write and Erase.
The basic idea behind object oriented programming is that if we can write code that mimics real world objects, like pencils, cars, customers, payments, etc. then it will make programming a lot easier. This is a gross over-simplification however it’s a starting point.
Consider a car as an example of a real-world object oriented system that is comprised of many discrete parts. The car itself is an object. The engine inside the car is an object. The exhaust system is an object that contains even more objects. The engine depends on the exhaust system, but it has no idea how the exhaust system works. Even though the car parts don’t know much about each other – except how to connect to each other – amazingly the parts all do their individual jobs and the end result is a working machine. If one part goes bad, it can be replaced without adversely affecting the rest of the car.
Additionally, you don’t have to know anything about how a car works in order to drive it. You sit down in a comfortable seat, turn on the ignition key, and operate the steering wheel, the gas pedal, the brake and occasionally a turn signal. However, your instructions trigger hundreds of individual parts without you having to worry about them. This focuses on a major OO concept called Encapsulation. All of the powerful engine and navigation components are encapsulated behind two or three controls that you (the user) work with.
To extend this example further, there are specifications that define what a car is in general – if not in reality, then at least in our minds -- and each automaker inherits and extends those specifications to give their car a unique look, performance benefit or price benefit. In other words, each automaker inherits from the ideal “car” to create a more specialized car. Still, from a programmer’s perspective, the Hyundai and the Mercedes have more in common than they have differences. The same general engine design, exhaust system design, number of tires, operation of the steering wheel, seats, pedals, turning signal, etc. exist in both cars. They both borrow from the design and mechanics of how a car works. In software terms, this is referred to as Inheritance, another important concept in Object Oriented Programming.
Also, all cars can go to the same gas stations and fill up using the same gas pumps, despite the fact that a Mercedes may cost
Supplemental Readings for the Express Edition Videos Copyright © 2005 LearnVisualStudio.NET