14
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer Video presenations Review questions

Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Embed Size (px)

Citation preview

Page 1: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Guided Notes Ch. 9 ADT and Modules

Ch. 10 Object-Oriented Programming

PHP support for OOP and Assignment 4

Term project proposal

C++ and Java Designer Video presenations

Review questions

Page 2: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

OOP: Early History

• OOP languages began in the 1960s with Simula project (extend Algol60 for simulation) => Simiula67

• Simula67’s influence took 2 different directions:

• Abstract data type (classes)

• Object paradigm (program = a collection of interacting independent objects) => Smalltalk-80

Page 3: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

OOP: Development

• Beginning in the mid-1980s, object-oriented programming => a language paradigm and a methodology for program design

• Extremely effective mechanism for promoting code reuse and modifiability => dominant paradigm for large software projects

Page 4: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Major concepts of OOP

• Address to 3 issues in software design:• Need to reuse software component as much as

possible

• Need to modify program behavior with minimal changes to existing code

• Need to maintain the independence of different components

• Abstract data type vs. OOP – improved solution to above design problems

Page 5: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Five Basic OOP Elements

• Extension of the data and/or operations

• Restriction of the data and/or operations (info hiding, encapsulation, protection)

• Redefinition of one of more of the operations

• Abstraction (abstract method)

• Polymorphism (overloading and overriding)

Page 6: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Code centric and data centric

• Procedure language (code centric) – code the application in functions/procedures using parameter passing sent in/out data. Function does the transformation – data and function separation

• OOP language (data centric) – objects, which represent their data internally, contain functionality called methods – data and behavior exist together less thinking and better organized

Page 7: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Terminology of OOP

• Encapsulation: the only code that changes an object’s data structure is in the class easier maintenance

• Inheritance: a way of defining a new class by saying that it’s like an existing class

Page 8: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Polymorphism

• An OO feature that gives us the ability to treat an object in a generic manner.

• Invoke a behavior on existing classes for any new classes with extension and leave the details and differences to the interpreter at run time

• Different classes can have different behaviors for the same operation (PHP book page 130 example: display())

Page 9: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Overloading and Overriding

• Overriding – fancy kind of polymorphism is resolved at runtime. It occurs when one class extends another, and the subclass has a method in the super-class. The reason for“fancy” is that you can’t tell until run time.

• Overloading – trivial kind of polymorphism, resolved by the compiler at compile time. Overloading allows several methods to have the same name, and the compiler will choose by matching on argument type

Page 10: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

3 levels of Name Spaces

• Must put a $this -> keyword in front of the member name (differs from Java or C++ where is optional, $this keyword tells PHP the variable from the object’s name space)

• 3 levels of name spaces:– Lowest level for local variable inside functions or

methods

– Middle level for the members of an object

– Highest level for global variables

Page 11: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Abstract method

• A method contains no code and implementer of any possible subtypes must implement the behavior for that method

• Show PHP book Example page 131-132

• The class-function call operator – ClassName::functionName( );

(page 132 bottom)

Page 12: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

PHP’s Limitations

• No static members (like a global variable but it is tied to class name space)

• No Destructors for PHP 4 (clean up when script is finished executing)

• No multiple inheritance

Page 13: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

PHP for this week and Assignment 4

• PHP include files

• Language reference:• Classes and objects

• Control structures – include, require

• Chapter 5 of PHP book

Page 14: Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer

Review Questions

• How Simula67 influenced programming language development?

• What are the 3 software design issues that motivate OOP development?

• What are the major difference between procedure oriented programming and object oriented programming?

• OOP terminology: Encapsulation, Inheritance, Polymorphism, abstract method