170 likes | 185 Views
Introduction Object-Oriented Programming. The Journey So Far. Procedural Programming. using Pseudocode. You are here. The Destination. Procedural Programming. Object Oriented Programming. using Pseudocode. using Java. Introduction.
E N D
The Journey So Far Procedural Programming using Pseudocode You are here
The Destination Procedural Programming Object Oriented Programming using Pseudocode using Java
Introduction • We are going to introduce two concepts at the same time: • Object-Oriented Programming • Programming in a real language • Why? • Pseudocode is a good preparation for learning any language. • The Object Oriented paradigm is a significant factor in modern programming • We feel that an introductory course should at a minimum give students a good taste of real programming • Many students have asked for exposure to a real language • Excellent preparation for CS 1312
Introduction • We will not abandon the principles you have learned so far: • modularity • abstraction • the necessity to visually validate the logic • Today we will give some basic ideas about: • Object Oriented Programming • Working with a real language: 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
The Scenario • 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 sucha 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
Queue Enqueue Dequeue Acme Manufacturing Issues • We’d like a way to put a “wrapper” around our structure to protect against intrusion. 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
CountingQueue Enqueue Size Dequeue Acme Manufacturing Issues • I need a queue that can tell me how many items it contains... Queue Enqueue Dequeue Acme Manufacturing “Magic Process”
Signal Car $ Student BankAccount Issues Elevator Signal Object Elevator Object Student Object Car Object BankAccount Object Real World Objects!