Archive for the ‘Programming’ Category

OOP and Programming Languages Overview

Monday, June 9th, 2008

When students begin learning about programming, they often are confused by the history of programming languages and their evolution. Don’t get caught up in trying to memorize the different generations of programming languages. Just remember that the programming world changed a lot over the past 40 years. Things really changed when OOP (object-oriented programming) came on the scene in the late 1980 – early 1990 time frame. Today, most core programming is done using OOP. What is OOP, you may ask?

First, let’s define a programming language, which is an artificial language created to allow humans to speak to a computer. Everything typed by a human is captured by a keyboard, translated to electronic signals, and sent to the computer (which interprets the electronic signals against its own language database). The computer then executes the electronic signals (instructions) received, usually placing something on the screen, printer, etc.

Let’s consider an OOP example based on the real world as we see it. As you are aware, a mammal is quite different from a reptile. Further, we could say that skin, diet, and climate requirements differ for each type of living thing. Therefore, each living thing could be viewed as an object with the unique qualities we mentioned above. These unique qualities are known as its attributes. There we have it: a very brief explanation of OOP.

If you study the mammal world you would no doubt notice that all mammals have a few things in common in that they nurse their babies with milk from mammary glands and have hair, even if that hair is barely noticeable. (Yes, I am a mammal!) With this in mind, we could look further at mammals and notice that some live on the ground whereas others live in the water (there are many differences, I just picked this one). In fact, there are 11 groups of mammals!

Now, let’s play genetics with a programming flair. If we could start out by creating a generic mammal class object with the two required attributes, we should be able to create all other mammal groups based on this base object (for example, the primate and marine groups). In the programming world, we would say that we first created a class (mammal) and the two other groups inherited the attributes of their base class. In other words, we didn’t have to recreate the mammal for each group; we just used its existing structure.

To take this one step further, we could account for allowing (or recognizing) how a group changes from its base class. For example, a mammal may or may not have teeth! Primates have teeth, whereas the sloth, armadillo, and anteater are toothless. Change such as this can be described as polymorphism, which is where a derived class (toothless or toothed) changes on its own (by a programmer) and is now different – but still somewhat the same – as its base class (the mammal).

Well, there you go! A deep, brief review of object-oriented programming. Now, on your own, construct a human class, and, using the concepts above, morph down to a 40 year-old female of average height, weight, and build, living in Roseburg, Oregon. That ought to keep you busy for a little while.

Visual Basic and C++ are two examples of object-oriented programming languages and programmers use Microsoft’s Visual Studio environment to construct objects (such as forms and windows) and attach these object to programming code. The Oregon Institute of Technology has a great software engineering program. Here, students learn how to program in a variety of programming languages, including C++ and Visual Basic. They also learn how to engineer a product, which is much more than programming. Calvin Caldwell is a great professor and a friend I’ll never forget.

Web pages are creating using one or more programming languages. Most Web pages (notice the capitalized “W”) are programmed using HTML (hyper text markup language) or one of its variants (XHTML or DHTML). Have you noticed how some web pages personally greet you by name after you log in? This is usually done using another Web programming language, JavaScript. Since we mentioned logging in, it’s probably good to mention that your username and password were picked up from the Web page, presented to a database, and then accepted or rejected. This is done using another Web programming language, usually PHP (an old acronym meaning personal home page, eventually changed to what’s called a ‘self referencing’ acronym known as PHP: Hypertext Processor). PHP allows programmers to use Web pages in conjunction with databases.