The difference is in the way the code is set up. In object oriented programming you have objects that have properties and can do something. Structured programming uses just functions.
A good way to think of object oriented programming is this:
Picture an elevator
its properties (variables it knows) would be things like currentFloor, floorRequested, doorOpen, etc.
its methods (functions) could be goToFloor(), openDoor(), etc.
Using object oriented programming you can better encapsulate your data. Instead of always having to send a function call a variable that was created in a related function just before, you can have the object remember the variable in its own scope and use it in all related functions.
2006-07-17 05:57:12
·
answer #1
·
answered by John J 6
·
0⤊
0⤋
Structured programming has code that runs from top to bottom, in a list. Each line of code is labeled, and parts of the program can be run multiple times by using loops and GOTO statements. Small, simple programs run fine - but adding new features can be difficult as the complexity of the code increases. An example of a structured language was BASIC.
Object-oriented programming (OOP) is a philosophy that views code in context of "what it is" and "what does it do". For example, a person has a name, an age, an ID (like a social security number), and other features. If we wanted to program a game with virtual people (like the Sims, or some role playing game), we would program our virtual person to have these attributes. We would also add code to let our virtual person eat, walk, talk, etc.
This would be some OOP code:
-------------------------------------
andy = new Person() --> creates a Person called Andy
andy.age = 23 --> sets Andy's age
andy.eat("pizza") -->makes Andy eat pizza
OOP allows programmers to create "classes" of objects with different features, characteristics, and functions. These software objects can represent things in the real world, and allows developers to add and update features that could require a complete re-write in structured languages. New languages use OOP, such as .NET, Java, and PHP.
Cheers,
Andy
2006-07-17 13:34:17
·
answer #2
·
answered by xx342334234234 2
·
0⤊
0⤋
Structured programming has steps
do step one, then step two, then step three, etc. until all of the steps are done
Object Oriented, Event Driven (OOED) programming can jump around:
The user clicks one button, a certain action happens....the user clicks a checkbox in a different location, something else happens. The OOED programming is more spontanious, in response to the interaction with the user.
2006-07-17 12:19:18
·
answer #3
·
answered by Richard H 7
·
0⤊
0⤋