Wednesday, June 23, 2010

Object-Oriented Programing

Object-Oriented Programming (OOP) is a type of programming approach that involves using "objects" (data structures) consisting of datafields (attributes) and methods (classes). These along with tools from the specific OOP language help programmers design applications and computer programs.

Some OOP languages include: Common Lisp, C++, C#, ColdFusion, Delphi (Object Pascal), Java, PHP, Python, VBScript, X++ and many others. Here is a site that lists them: wiki (note it is Wikipedia, and there were too many languages to go through to verify the information. I will eventually use each one as a topic for this blog).

Some common features are seen in OOP, which include: abstraction, encapsulation, inheritance, and polymorphism. These features help reduce code duplication, and promotes code reuse. If these are mastered properly then programs can run more efficiently, have less lines of code, and become easier to manage and update.

Why is OOP so special? Why should anyone learn it? Well it is special because instead of the old model of having a program doing a list of tasks, a program is divided into classes that give the blue print of how an object should behave and be created. In OOP "objects" are models of real world objects. Lets say you have objects that are animals, and they want to walk in your program. OOP makes just one class that the animal objects can call in order to all walk. The old model had to keep creating the same walking code over and over for each animal.

Lets say their are many specie objects that are related, and have similar attributes. OOP makes coding this example simply with inheritance. You can have a main class animal that describes the attributes of an animal, then you can have different types of specie classes that describe specific specie objects' attributes under that. The species classes can inherit the same attributes as the main class animal with the inheritance feature. With the old module you had to create code over and over for each attribute for all the different types of species. [1] site of picture The picture shows a class inheritance hierarchy, but adds a few levels like pet and livestock. Mostly same idea.





These are just some of the ways that make OOP so powerful as a type of programming language. I will go into more detail and explanation when i talk about Programming Logic and Design.

Links: Procedural vs. OOP
OOP explained
Sources: i have include C++, C#, Java with BlueJ, and Visual Basics books. I may have more books on OOP fundamentals. In later posts i will get into more detail on OOP because it is such a broad topic. This was mainly just a small summary of what OOP is with an example of inheritance, objects, and classes.

No comments:

Post a Comment