Upload
ocean-peterson
View
17
Download
0
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
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:
Interfaces: “neatest” way for programs to deal with eventsAbstract classes
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
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 …
Compiler checks to see if it complies with the interface declaration
Examples: Programs that use Buttons implement ActionListeners and Scrollbars AdjustmentListeners
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
Multiple Inheritance
Some languages (C++) not JavaJava allows multiple implementations Example programs: “Entertainment” and program “TV” which extends “Entertainment”
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
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)
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