I am in the middle of my IT class (my science requirement). They call it a beginners class, but I am apprently even lower than a beginner on the ladder...if anyone can help me make heads or tales of this question I would really appreciate it....xox
What are the most important differences between object-oriented programming
languages and generations 1-4 of (often called top down or structured) programming
languages. How are they similar?
Object oriented programming languages are typified by C++. It has classes. Let me give you an example; you create a class called "people". Then "people" have a property called "sex". The property call sex has two types "male" and "female". This is written as people->sex = male or people->sex = female. people also have a property called "limbs". limbs have types, "arms", "legs", "fingers", "toes". This would be written as people->limbs = legs. A new class can inherit properties and types from existing classes. For example, a meta code (meta means not real code, but a rough example for your understanding)
Define programmers as new class of people
An example of this would be:
programmers->sex = male
programmers->limbs=arms
and so on.
Structured programming languages are usually defined as having as structured logic that you can easily follow.
The programming language that first allowed for structured programming was Pascal. We no longer use Pascal much anymore. Microsoft Visual Basic is used, and it is structured. It no longer uses line numbers or goto statements.
An example of this would be:
If age < 2 then
'you are an infant
'you just learned to walk
'you are still learning to talk
else if age > 2 and age < 5 then
'you are a toddler
'you have learned to walk
'you have learned to talk
else
'you are more grown up
End if
You can see how each age level is clearly laid out, we call this "Structured Programming".
An example of unstructured or "Spaghetti" code. It is call "Spaghetti" code because the logic thread twists and turns, and is very hard to follow and unravel. An example of this is "Dartmouth Basic", this was the original version of basic. It used line numbers to direct the flow of the logic thread.
An example of this would be:
10 If age < 2 then goto 100
20 If age > 2 and age < 5 then goto 110
30 If age => 5 then goto 120
note, we can skip lines. We need to in case we need to insert a lien of code, and the "goto" statement is used quite often in unstructured code.
100 'you are an infant
102 'you just learned to walk
104 'you are still learning to talk
106 goto 500
110 'you are a toddler
112 'you have learned to walk
114 'you have learned to talk
116 goto 500
120 'you are more grown up
500 End
As you can see, unstructured code is much harder to read and understand. Large amounts of code can be impossible to follow and understand.
I hope this helps explain the subject.