Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction (Continued) Design Patterns (I) Lecture Two.

Similar presentations


Presentation on theme: "Introduction (Continued) Design Patterns (I) Lecture Two."— Presentation transcript:

1 Introduction (Continued) Design Patterns (I) Lecture Two

2 What is a framework Like a class library, but more than an ordinary toolkit. The framework components have structural and behavioral relations among them. Domain specific: –business, telecom, window systems, databases, OS kernels, …

3 What is a framework An integrated set of cooperating classes –architectural design of oo system –semi-complete application set of abstract class are specialized in application

4 Frameworks Inversion of control –main event loop is often in framework, rather than in application code –hollywood principle: don’t call us, we’ll call you –code in framework can invoke code in application by dynamic binding

5 Framework examples UI –model-view-controller (MVC) framework for smalltalk user interfaces [1980] –macapp - framework for Mac applications [1986] Others –MFC - Microsoft foundation classes –Choices - operating system framework –…..

6 Patterns vs Frameworks Patterns –reuse of design –tells you how to do good design –language independent –often covers general domains –addresses small part of a program architecture

7 Patterns vs Frameworks Framework –reuse of design and code –is a design (generic implementation) –language specific –often covers specific domain –addresses overall program architecture

8 State Pattern Butterfly Example –Caterpillar –Chrysalis –Adult Happy/Gloomy Example

9 State Pattern Book discussion –Applicability: state dependent behavior large conditional statements –Scheme: structure/participants/collaborations –Benefits extensibility make state transitions explicit can be shared (flyweight)

10 State Pattern Implementation –Who defines state transitions? –How about table-driven –Manage lifetime of state objects relation with Singleton –How about use dynamic inhertiance

11 Singleton Pattern What is it? How to implement?

12 Homework: Digital Watch Demo Code explained

13 Composite Pattern Objective: treat primitives and containers uniformly java.awt.* Example Basket

14 Composite Pattern Consequences –recursive composition –uniform interface –easier to add new components –can make design overly general

15 Implementation Issues Explicit parent references Sharing components Maximizing the Component interface Child management operations Who implements a list of components Child ordering Who should delete components Best structures for storing components


Download ppt "Introduction (Continued) Design Patterns (I) Lecture Two."

Similar presentations


Ads by Google