Introduction Object-Oriented Programming Reprise
The Journey So Far Procedural Programming using Pseudocode You are here
The Destination Procedural Programming Object Oriented Programming using Pseudocode using Java
Introduction You have now have a taste of programming in a real language Now we move more deeply into the Object Oriented Programming Paradigm The Object Oriented paradigm is a significant factor in modern programming Typical OO Languages include C++, Smalltalk and, of course, Java.
Object Oriented Programming A different programming style A different way of thinking Origins Problems with very large systems becoming unmanageable (> 100,000 lines of code) Graphical User Interfaces (e.g. Macintosh, Windows) required a different way of programming due to complex interactions of windows, mouse clicks, etc. Xerox PARC: Smalltalk C++ as an enhancement to C Java as a Web language
To be more specific...
The Scenario Items Recall the concept of a Queue: Defined by a set of behaviors Enqueue to the end Dequeue from the front First in, first out Items
Where is the Queue? The logical idea of the queue consisted of: Data stored in some structure (list, array, etc.) Modules to act on that data But where is the queue? We’d like some way of representing such a structure in our programs.
Why? We would like to have reusable “drop-in” programming components we could use to solve problems. We would like to encapsulate the data and the behaviors in order to “protect” it from misuse. We would like clear interfaces between different parts of programs We would like a programming system that was extensible We would like a programming language that would be excellent for modeling real world objects
Issues As is, there is no way to “protect” against violating the specified behaviors. Procedure Enqueue Procedure Dequeue The Queue Data Sneak into Middle
Issues If our queue could somehow be packaged we could drop in a “queue object” whenever we needed it. Queue Acme Manufacturing
Issues We’d like a way to put a “wrapper” around our structure to protect against intrusion. Queue Acme Manufacturing Enqueue Dequeue Sneak into Middle
Issues Contract The party of the first part hereinafter known as the queue agrees to... The party of the second part hereinafter known as the application agrees to... Clear lines of responsibility
Issues I need a queue that can tell me how many items it contains... Queue Enqueue Dequeue Acme Manufacturing “Magic Process” CountingQueue Acme Manufacturing Enqueue Dequeue Size
$ Issues Signal Elevator Signal Object Elevator Object Student Student Car Object Car $ BankAccount BankAccount Object Real World Objects!
Questions Why do we have the procedural paradigm and the object oriented paradigm? Is procedural programming used for certain problems and object oriented programming used for others?