CyberArmy University | Open Source Institute | CyberArmy Intelligence & Security | CyberArmy Privacy Watch Initiative

[CyberArmy] What is: Object Oriented Programming?


[Reply] [View by Thread] [Help]
[Back To Article Discussion Forum]

Posted by Author Ikioi On 2007-04-29 10:01:37




View and vote on the article here: What is: Object Oriented Programming?


What is: Object Oriented Programming?

Category
CyberArmy
Summary
Object Oriented Programming, also known as OOP, is a term that many of you may have heard, but don't understand. Those who are interested in programming may wonder if it is something they should learn. Is it professional or just something that amateurs
Body
OOP is definitely not a fad, nor is it just for amateurs. OOP is a professional method of programming with a very long history. It was developed in the 1960s, and has been built into many programming languages over the years. More recently, it has even become the entire basis of some programming languages. There are a fair number of popular languages that either do or can use object oriented programming, and you have probably heard of some or all of them: C#, C++, Delphi, Java, Perl, PHP, Python, Ruby, and Visual Basic, just to name a few.

However, to understand what object oriented programming is, it might help to explain a bit about programming. Here's a program:

10 Start
20 Print ?Hello World?
30 End

This is a simple program that might have been written years ago. Today, although programming is more complex, this example still works for the purposes of our discussion. This type of programming is called linear programming. The program does a, b, and then c, in that order. Programming has since evolved into a more structured system, where programs are broken down into smaller pieces, and OOP is part of this evolution. Here is a Hello World program in OOP. It is not actual code for any specific language.

Start
class Hello {
define $message
function capitalizeEverything($phrase) {
... = $message
$this-message=$message
}
}

function pageTitle($x) {
// Writes $x into the page title
.....
}

define $obj1
define $obj2
$obj1 = new Hello(?hello world?)
$obj2 = new Hello(?howdy yall?)

if $user = bob
pageTitle($obj1)
endif

if $user = amy
pageTitle($obj2)
endif
End

So, here's what happens. If the user is bob, the page title will say Hello World. If the user is amy, the page title will say Howdy Yall. What happened is that two objects were created, obj1 and obj2. By creating these objects, you can embed data into them, and then use that data directly. The alternative would be to write the function calls out each time. Using OOP, you can not only create objects, but layer and call different methods depending on where it is used. This is known as Polymorphism.

You might have a single object that is made up of dozens of other objects, which are in turn made up of dozens of other objects. To call and change the entire set of objects, the only command you might need is $masterobject-transform($array);

To use a different analogy, think of Earth as one giant object. Each country is an object inside the Earth object, and this continues all the way down through counties, cities, and neighborhoods, all the ay down to individual people. If you $Earth-makePeace, it might result in every $person-makeHappy. However, instead of doing billions of makeHappy commands, you only need to issue that single command. This is one of the ways that OOP simplifies programming.

For small projects and scripts, OOP may not appear very useful. However, if you are a serious programmer (or a person looking to seriously learn programming), object oriented programming will be critical to you.

If you already know programming, it is easy to learn. If you don't know programming, it may be even easier to learn. OOP allows you to step away from the code and see the big picture by using only a few objects. This is similar to the above method of taking the complexity of everything on Earth and simplifying it to the single object Earth.

To learn more about OOP, I suggest you look for information related to the specific language you currently use or are interested in learning. Be sure to check out available information at the Open Source Institute's website http://www.osix.net.

More Links

Object Oriented Analysis and Design
http://www.zzine.org/read.php?op=view&item=854

PYTHON, the OO powerhouse
http://www.zzine.org/read.php?op=release&item=16#2

Why Python? why Literate programming?
http://www.osix.net/modules/article/?id=222
(Note that capitalization is correct)

Python Tutorial part1
http://www.osix.net/modules/article/?id=160


This article was imported from zZine. (original author: Ikioi)


There are no replies to this post yet.



Guest:
Subject:
Message:
Signature:
Optional Image Link:
http://

CyberArmy::Forum v0.6
Generated In 0.01692 seconds


About Us | Privacy Policy | Mission Statement | Help