Book Description

About the Author

Table of Contents

Source Code

Send Comments

Author's Homepage
 

Object-Oriented Software Development Using Java
Xiaoping Jia, Ph.D
Chapter 5: Design by Abstraction

Objectives
In this chapter, we will introduce design patterns. The main focus of this chapter is designing reusable, and flexible components using abstract classes, interfaces, and design patterns. We will discuss several important design patterns for abstraction: Template Method, Strategy, Factory, and Iterator. A case study will also be presented. 


Contents
5.1 Design Patterns
5.2 Designing Generic Components
      5.2.1 Factorization
      5.2.2 Generalization
      5.2.3 Abstract Coupling
5.3 Design Case Study_ Sorting Animation
      5.3.1 The Initial Implementation
      5.3.2 Separating the Algorithms
      5.3.3 Separating the Display Strategies


Source Code

  • 5-1: Generic animation applet 
  • 5-2: Double buffered animation applet 
  • 5-3: Function plotter applets 
  • 5-4: A multiple function plotter applet 
  • Case Study: Animated Sorting applets 


  • Other Chapters

    Example 5.1: A Generic Animation Applet 
    This example demonstrates factorization by inheritance. A generic animation applet class AnimationApplet is defined by extracting the common elements of animation applets, the methods start(), stop(), and run(). Then, the digital clock applet in Example 3.10 is re-implemented using the AnimationApplet class. Hence, there are two Java programs to download. 

    Example 5.2: Double Buffered Generic Animation Applet 
    This example illustrates how to resolve the complications involved in factorization by inheritance. It also addresses issues concerning flexibility, i.e., adaptability, in the generic animation applet. A double-buffered generic animation applet class DBAnimationApplet is defined using factorization by inheritance. Then, the bouncing ball applet is re-implemented using the DBAnimationApplet class. Again, there are two example Java programs to download. 

    Example 5.3: Function Plotter Applets 
    The Plotter applet is a generic funtion plotter applet for plotting arbitrary single variable functions on a two-dimensional canvas. This example shows several concrete programs in action. 

    Example 5.4: A Multiple Function Plotter Applet 
    This Plotter applet demonstrates the Template Method design pattern. This is a generic funtion plotter applet for plotting arbitrary single variable functions on a two-dimensional canvas. This example implements two concrete functions, Sine and cosine. 

    Case Study: Sorting Animation 
    The following are various examples of sort applets. 

    Book Description - About the Author - Table of Contents
    Source Code - Send Comments - Author's Homepage

    Webmaster: rpasenko@shrike.depaul.edu