+ All Categories
Home > Documents > Reuse Activities Selecting Design Patterns and Components Part (2)

Reuse Activities Selecting Design Patterns and Components Part (2)

Date post: 22-Dec-2015
Category:
View: 225 times
Download: 4 times
Share this document with a friend
Popular Tags:
24
Reuse Activities Reuse Activities Selecting Design Patterns Selecting Design Patterns and Components and Components Part (2) Part (2)
Transcript
Page 1: Reuse Activities Selecting Design Patterns and Components Part (2)

Reuse ActivitiesReuse ActivitiesSelecting Design Selecting Design

Patterns and Patterns and ComponentsComponents

Part (2)Part (2)

Page 2: Reuse Activities Selecting Design Patterns and Components Part (2)

OutlineOutline

• Encapsulation Control Flow with the Command Pattern.

• Encapsulation Hierarchies with the Composite Design Pattern.

• Heuristics for Selecting Design Patterns.

• Identifying and Adjusting application framework.

Page 3: Reuse Activities Selecting Design Patterns and Components Part (2)

• Problem:

We don’t want the classes responsible for recording and replaying moves to depend on specific game.

• Solution:

Using Command Design Pattern.

Page 4: Reuse Activities Selecting Design Patterns and Components Part (2)

Match

Play()

Replay()

Move

Execute()

Execute()Execute()

ChessMoveTicTacToeMoveGameBoard

binds

*

Command Design Pattern uses specification inheritance between command class and concrete command enabling new command to be added independently from the invoker.

Page 5: Reuse Activities Selecting Design Patterns and Components Part (2)

• Delegation is a way of making composition (for example aggregation) as powerful for reuse as inheritance.

• In Delegation two objects are involved in handling a request:– A receiving object delegates operations to its delegate. – The developer can make sure that the receiving object

does not allow the client to misuse the delegate object

Client Receiver DelegateDelegates to calls

Page 6: Reuse Activities Selecting Design Patterns and Components Part (2)

Delegation is used between concrete commands and receivers, and between invoker and command enabling concrete command to be dynamically created, executed and stored.

Main

Page 7: Reuse Activities Selecting Design Patterns and Components Part (2)

Encapsulation Hierarchies with the Encapsulation Hierarchies with the Composite Design Pattern.Composite Design Pattern.

Definition: A software system consists of subsystems which are either other subsystems or collection of classes

Composite: Subsystem (A software system consists of subsystems which consists of subsystems , which consists of subsystems, which...

SoftwareSystem

ClassSubsystem Children

*User

Page 8: Reuse Activities Selecting Design Patterns and Components Part (2)

Grid layout(3,4)

Border layout

Border layout

Page 9: Reuse Activities Selecting Design Patterns and Components Part (2)

Composite Design PatternComposite Design Pattern

Component

Move()

Resize() Composite

Move()

Resize()

Applet

window Panel

Label Button Checkbox

*

Main

Page 10: Reuse Activities Selecting Design Patterns and Components Part (2)

Heuristics for Selecting Design Heuristics for Selecting Design Patterns.Patterns.

Using key phrases in the Requirement Analysis Document (RAD) and System Design Document (SDD).

Heuristics box

Page 11: Reuse Activities Selecting Design Patterns and Components Part (2)

Phrase Design Pattern

“Manufacturer independence”

“Platform independence”

Abstract factory

“Must comply with existing interface”

“Must reuse existing legacy component”

Adapter

“Must support future protocol” Bridge

“All commands should be undoable”

“All transactions should be logged”

Command

“Must support aggregate structures”

“Must allow for hierarchies of variable depth and width”

Composite

“Policy and mechanisms should be decoupled”

“Must allow different algorithms to be interchanged at runtime.”

Strategy

Main

Page 12: Reuse Activities Selecting Design Patterns and Components Part (2)

Application Framework DefinitionApplication Framework Definition

An application framework is a reusable partial application that can be specialized to produce custom applications. Frameworks are targeted to particular technologies.

Page 13: Reuse Activities Selecting Design Patterns and Components Part (2)

Examples of application Examples of application FrameworksFrameworks

Examples

Data processingCellular

communicationsApplication domain

Page 14: Reuse Activities Selecting Design Patterns and Components Part (2)

FrameworkUseful to

Reusability Extensibility

Application domainknowledge

Prior effort of experienced developers

to avoid recreation and validation

By providing Hook methods

Page 15: Reuse Activities Selecting Design Patterns and Components Part (2)

Framework classificationby position

Infrastructureframeworks

Middlewareframeworks

Enterprise applicationFrameworks

Page 16: Reuse Activities Selecting Design Patterns and Components Part (2)

Infrastructure Middleware Enterprise application

Aim to simplify software development process. Used internally within software project

Used to integrate existing distributed application and components.

Focus on domains such as telecommunicati-ons

Are essential to create rapidly high quality software systems

Support the development of end user applications.

Page 17: Reuse Activities Selecting Design Patterns and Components Part (2)

FrameworkClassificationby techniques

WhiteboxFramework

BlackboxFramework

Page 18: Reuse Activities Selecting Design Patterns and Components Part (2)

Whitebox• Rely on inheritance and

dynamic building for extensibility.

• Existing functionality is extended by subclassing framework base classes and overriding predefined hook methods.

Blackbox• Support extensibility by

defining interfaces for components that con be plugged into the framework.

• Existing functionality is reused by defining components that conform to particular interface.

Page 19: Reuse Activities Selecting Design Patterns and Components Part (2)

• Require intimate knowledge of the framework’s internal structure.

• Produce systems that are tightly coupled to the specific details of the framework’s inheritance hierarchies, thus change in framework require recompilation of application.

• Easier to use because of delegation.

• More difficult to develop because require definition of interfaces and hooks.

• Easier to extend and reconfigure dynamically.

Page 20: Reuse Activities Selecting Design Patterns and Components Part (2)

Design patterns versus frameworksDesign patterns versus frameworks

Design pattern

Focus on reuse of abstract designs and small collections of cooperating classes.

Can be viewed more as building blocks of frameworks.

Framework

Focus on reuse of concrete designs, algorithms and implementations in a particular programming language.

Focus on particular application domain.

Page 21: Reuse Activities Selecting Design Patterns and Components Part (2)

Class Libraries versus FrameworksClass Libraries versus Frameworks

Class librariesLess domain specific and

provide smaller scope of reuse. eg: classes for strings, complex numbers, arrays and bitsets.

Passive: don’t implement constrain the control flow.

FrameworksCooperate to provide a

reusable architectural skeleton for a family of related applications.

Active: control the flow of control within an application.

Page 22: Reuse Activities Selecting Design Patterns and Components Part (2)

Components versus FrameworksComponents versus FrameworksComponents

Self contained instances of classes that are plugged together to form complete applications.

It is a blackbox that defines a cohesive set of operations that can be used solely with knowledge of the syntax and semantics of its interfaces.

Less tightly coupled and can be reused on the binary code level.

Application don’t always have to be recompiled when components change.

component interface provides a façade pattern for the internal class structure of the framework.

Can be plugged into blackbox framework.Used to simplify the development of end user

application software.

FrameworksCan be used to

develop components.

Used to simplify the development of infrastructure and middleware software.

Components are often plugged into blackbox frameworks.

Page 23: Reuse Activities Selecting Design Patterns and Components Part (2)

Example: Framework for Building Example: Framework for Building Web ApplicationsWeb Applications

WebBrowser

RelationalDatabase

StaticHTML

WOAdaptorWebServer

WoRequest Template

WebObjectsApplication

WORequest

EOF

Page 24: Reuse Activities Selecting Design Patterns and Components Part (2)

Thanks for your attention


Recommended