In this lecture, you will learn the following commonly-used software design patterns.
Factory Method: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. [GoF, p107]
Abstract Factory: Provide an interface for creating families of related or dependent objects without specifying their concrete classes. [GoF, p87]
Adapter: Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. [GoF, p139]
Bridge: Decouple an abstraction from its implementation so that the two can vary independently. [GoF, p151]
Facade: Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. [GoF, p185]
Strategy: “Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from the clients that use it.” [Gamma, p315]
References:
Huston Design Patterns. It contains demos and examples (in C++ and Java) to explain various design patterns. A good resource for learning by example.
The Design Patterns Java Companion is a free online book on Java Design Patterns.
Design Patterns, a Java resource from cs.rice.edu
Java Design Patterns Reference and Examples by FluffyCat.com
Comments Off
In the previous tutorial, you have gained some insight into the Observer pattern. In this tutorial, you will consolidate your understanding about the Observer pattern by experimenting more programs that use the Observer pattern.
References:
Keeping Objects In Sync
Building Graphical User Interfaces with the MVC Pattern
Comments Off
In this lecture, we start to learn object design and design patterns.
Object design is about identifying additional solution-domain objects and refining existing objects. Object design includes the following activities:
- Reuse–use inheritance and composition/delegation, identify off-the-shelf framework, and apply design patterns
- Service specification–describe interface of classes precisely
- Restructuring–transform the object model to increase code reuse or meet other design goals such as readability and maintainability
- Optimization–address performance goals such as response time and throughput
Design patterns take the reuse concept a step further. A design pattern encapsulates a specific way that a number of different objects work together. Different design patterns can be applied in certain situations to achieve specific benefits.
Your actions before next class: Read Chapter 8 Object Design: Reusing Pattern Solutions.
1 Comment
In this tutorial, you will do a practical exercise about Observer design pattern.
You will given a simple program which uses a GUI to display the state about a Person object. You are asked to consider how the Observer design pattern be used to ensure that the simple GUI interface can reflect the most recent state of the Person object.
You also need to write a driver program to verify that what you have done is correct in action.
References:
Observer (Java 2 Platform SE v1.4.2)
Observable (Java 2 Platform SE v1.4.2)
Java Programmer’s SourceBook : Thinking in Java : The observer pattern
Update:
More reference for Observer pattern in Java:
Keeping Objects In Sync
Building Graphical User Interfaces with the MVC Pattern
Comments Off
In the previous lecture, we have studied the concepts of design goals and subsystem decomposition. In this lecture, we go on to study the design activities needed to address the design goals and to refine the subsystem decomposition. In particular, we will study
- Mapping of subsystem to hardware
- Design of a persistent data management
- Specification of an access control policy
- Design of the global control flow
- Handling of boundary conditions
Your actions before next class: Read Chapter 7 System Design: Addressing Design Goals.
2 Comments
In this tutorial, we will have class discussion on system design basic concepts and software architecture.
The first discussion is about open layered architecture, closed layered architecture, and system coupling.
The second question is about the benefits of using architectural styles in system design.
In the third question, we compare the three-tier and MVC architectural styles to note their similarities and differences.
In the fourth question, we learn by examples the five categories of design goals: performacne, dependability, cost, maintenance, and end user.
Finally, to understand more about MVC architecture, you are asked to draw a sequence diagram to depict the MVC architecture.
Comments Off