11
Advanced Object Oriented Programming – Abstract classes and Interfaces Chapter 27

Advanced Object Oriented Programming – Abstract classes and Interfaces

Embed Size (px)

DESCRIPTION

Advanced Object Oriented Programming – Abstract classes and Interfaces. Chapter 27. Purpose: to simplify the design of medium to large sized programs. Advanced OOD concern with the identification of class structures and inheritance. Chapter facilities:. - PowerPoint PPT Presentation

Citation preview

Page 1: Advanced Object Oriented Programming – Abstract classes and Interfaces

Advanced Object Oriented Programming – Abstract classes and Interfaces

Chapter 27

Page 2: Advanced Object Oriented Programming – Abstract classes and Interfaces

Purpose: to simplify the design of medium to large sized programs

Advanced OOD concern with the identification of class structures and inheritance

Page 3: Advanced Object Oriented Programming – Abstract classes and Interfaces

Chapter facilities:

Interfaces: “neatest” way for programs to deal with eventsAbstract classes

Page 4: Advanced Object Oriented Programming – Abstract classes and Interfaces

Abstract classes – set up a class to be reused

Example program “Rectangle” See Author’s web site. Rectangle” extends “Shape” which is an abstract classDeclaring a class abstract forces programmer who uses it (via inheritance,) to provide missing methods – which “enforces” a particular design

Page 5: Advanced Object Oriented Programming – Abstract classes and Interfaces

Interfaces

Used in “Balloon” Public interface Balloon { … Note NO class An interface describes only the

services provided by the class

public class Spheroid implements Balloon …

Page 6: Advanced Object Oriented Programming – Abstract classes and Interfaces

Compiler checks to see if it complies with the interface declaration

Examples: Programs that use Buttons implement ActionListeners and Scrollbars AdjustmentListeners

Page 7: Advanced Object Oriented Programming – Abstract classes and Interfaces

Interface can be used to describe classes in a program

Inheritance structure “Is a” relationshipCan Not describe: Implementations of methods Classes which use other classes (“has

a”) relationship

Page 8: Advanced Object Oriented Programming – Abstract classes and Interfaces

Multiple Inheritance

Some languages (C++) not JavaJava allows multiple implementations Example programs: “Entertainment” and program “TV” which extends “Entertainment”

Page 9: Advanced Object Oriented Programming – Abstract classes and Interfaces

Interfaces versus abstract classes

1. Abstract classes can provide implementation of one or more methods2. Can implement more than one interface but only extend (inherit) from one abstract class3. An interface is something that is used at compile time to perform checking4. Abstract class implies it’s methods will be fleshed out by the class that extends it

Page 10: Advanced Object Oriented Programming – Abstract classes and Interfaces

Designing multithreaded programs

1. Use methods described in chapter 212. Analyze applications to see activities that need to be carried out in parallel3. Identify those objects that need to be threads4. Identify the nature of the interaction between threads (independent, mutual, exclusion, producer-consumer)

Page 11: Advanced Object Oriented Programming – Abstract classes and Interfaces

Other approaches:

Information systems: examples Airline ticket reservation system

Real time systems Fly by wire

Knowledge based systems AI

Parallel or concurrent systems Any computer systems that can carry on two or

more tasks simultaneously

Mathematical “complex” processingGames especially those with good graphics