2. Getting in the right frame of mind In this presentation we will review the concepts of OOP and POP. If you were the owner of an ATM machine, which paradigm do you hope the machine designers used? OOP POP 2
3. POP vs. OOP ATM Machine POP Hmmm…How much should I withdraw? Direct access to pile of cash Src: Flickr.com
4. POP vs. OOP ATM Machine OOP 4 Hmmm…How much should I withdraw? Src: Flickr.com Access through interface of machine. Withdraw
5. Procedure-Oriented Programming Program Structure: Program is a main method along with a collection of methods that act on the data in the program. Data:is unprotected, available to all methods in the program. Program Design: POP Programs are linear: program structure centered about a “main” control structure Programs have a distinct begin and end. Program design focuses on the steps required to produce the desired outcome. 5
6. POP Construction Identify the processes needed to get from Input to Output Technique: Top down Design with Step-wise refinement use “Divide and Conquer” to break a large problem into cohesive subproblems and solve each separately Subproblems become methods that are “Called” Represent the program design using pseudocode technique or Flowchart Write code from the design 6
13. 9 Object-Oriented Programming Object Data (Fields)typically private to this object Michaelangelo Methods That Operate on the Data length() Code Outside the Object (client) charAt() Name(a String object)
14. Object-Oriented Programming Program Structure: Program is a collection of objects that pass messages to each other. Data:is encapsulated in and protected by the object’s interface. Program Design: Two-dimensional model: program structure centered about objects that interact with one another No distinct begin/end, central control or path through the program. 10
15. OOP Joe’s Auto Shop 11 Truck mechanic Parts and Supplies Auto mechanic Database of fees
16. 12 What’s next….Classes and Objects Now how do we represent objects in Java code? Using a Class, of course