Object-Oriented Programming

 

The Object-Oriented Concept

Humans have been classifying things into "Objects" since the dawn of history because it is our natural tendency to do so. Computer languages that are oriented with these Object-Oriented Concepts tap into this natural human tendency resulting in an easy to understand and use language.

Every programmer knows that ten small programs are easier to debug that one program that is ten times larger. Several advancements have been made towards this concept. Subroutines, Sub-functions and now Objects. Object-Oriented programming will not, to be honest, live up to all the hype that you may have heard. If you think it will make all programming automatic, and all problems and bugs a thing of the past, you’ll be disappointed. Object-Oriented programming is, however, a significant advancement, and every programmer, that gains an understanding of Object-orientation, will become better and more productive.

An automobile is a very good example of the Object-Oriented Concept. As humans, it is our natural tendency to think of an automobile as a single "thing", and not as a large group of several thousand small "things". Thinking of the automobile as a single "thing" helps us deal with the overwhelming complexity of the whole machine. We would say simple statements like; "Fill her up." or "How fast are we going?" or "I have a Blue car." ... and everyone would understand how those statements apply to our car.

Using an automobile as an example of an Object, the following program shows an example of Object Oriented programming

    BobsCar.Speed = 50
    If BobsCar.Speed > CurrentRoad.SpeedLimit Then
      PoliceCar.Mode = Chase
      PoliceCar.Target = BobsCar
      PoliceCar.Speed = BobsCar.Speed + 10
    End If

As shown in the example, the overwhelming complexity of Bob's car is reduced down to a simple set of understandable terms. 

In Object-Oriented terminology, collecting together a large group of several thousand small "things" into one single "thing" called an automobile is called encapsulation. Once encapsulated, the individual components within an object are dedicated to that one object. As in the above example, both automobile objects have a Speed property.  Even though the property has the same name, each refers to its own object.  It should also be noted that each instance of the objects work continuously and simultaneously in the background just as the cars do in the example.


 

The OOP in OOPic

Any one who has programmed Embedded Controllers knows how complex they can get. OOPic eliminates this problem by encapsulating all the components of Microchip's PICmicro®, embedded controller's hardware circuits into Objects. During program development, these objects can be named appropriately and then used with simplified statements like Motor1.Speed = 50.  The OOPic has a large library Objects, each with a different predefined function.  Multitasking in an Embedded Controller is also a daunting challenge.   OOPic gracefully handles the multitasking issues by handling the processing requirements of each object in a cooperative multitasking arrangement.
For more information on OOP, see Chapter 6 of the Programmer's Guide.
Easy as...
RedLight = ON

-Or-

 
RedLight = OFF  

All contents copyright (c) Savage Innovations LLC. 1999-2008.
OOPic® and ooPICTM are trademarks of of Microchip Technology Inc.  These products are developed and distributed by Savage Innovations.  Savage Innovations is not an agent or representative of Microchip and has no authority to bind Microchip in any way.
PICmicro® is a registered trade mark of Microchip Technology Inc.