Download presentation
Presentation is loading. Please wait.
Published byDaniella Ball Modified over 9 years ago
1
University of Twente Meta Patterns Common Principles behind Design Patterns & OO Frameworks Lodewijk M.J. Bergmans
2
University of Twente IntroductionIntroduction This presentation is based on the work of Wolfgang Pree: "Design Patterns for OO Software Development" (book) "Meta Patterns - A Means for Capturing the Essentials of Reusable Object-Oriented Design" (ECOOP '94) Meta patterns describe a few generic structures and techniques that are repeatedly found in design patterns Relation to (GoF) design pattern catalog: vThese are solutions to design problems when attempting to construct flexible & adaptable frameworks vPree calls these: 'framework example design patterns'
3
University of Twente Hot spots a framework consists of two parts: va fixed, generic architecture of domain-knowledge independent of specific applications vflexible, application-specific parts (hot spots) ready as a library, or defined by the application programmer framework architecture: fixed part, (application-independent) hot spots: flexible parts, (application-tailorable)
4
University of Twente Template & Hook methods Template method: vdefines the fixed part vcalls the hook methods vimplements generic domain knowledge Hook method: vthe flexible part; to be (re-)defined vimplements application-specifics vcan be abstract method A (non-abstract) hook method can be again a template method itself mtmh1mh2 C1::mt C1::mh1 C1::mh2 C1
5
University of Twente Applying Templates & Hooks –1 Through subclassing: introduce a subclass C2 that (re-)defines method mh1 other hot spots (e.g. mh2) can be redefined as well adaptation without modifying the class C1::mt C1::mh2 mtmh1mh2 C1 C2 C2::mh1
6
University of Twente Applying Templates & Hooks –2 By invocation on another class classes interact through a fixed protocol ('contract') template method calls hook methods on another object different objects are possible through polymorphism this also allows for dynamic adaptation mtmh1mh2 C1C3 C4 ref... ref mh1.... ref mh2.
7
University of Twente Narrow Inheritance-Interface Principle We want a framework to be as flexible as possible: But the 'narrow inheritance-interface principle' (NIIP) says: vmake the adaptation interface as simple as possible
8
University of Twente Narrow Inheritance Interface Principle -2 NIIP attempts to: vavoid problems of white-box reuse vreduce effort in instantiating and adapting framework When invoking hook methods on another object: v'Narrow Calling Interface Principle' applies; minimize coupling by keeping protocols simple vbut because this is black box reuse (of the template class), this is less severe
9
University of Twente Composition Meta Patterns: Overview TH hook 1:1 Connection Pattern TH hooks 1:N Connection Pattern T H hook 1:1 Recursive Connection Pattern T H hooks 1:N Recursive Connection Pattern THhook 1:1 Recursive Unification Pattern THhook 1:N Recursive Unification Pattern TH Unification Pattern
10
University of Twente Exercise -1 Find the meta-patterns in the Bridge Pattern RefinedAbstr operation... Abstraction ConcrImpl1 operation Impl... Implementor ConcrImpl2 operationImpl... RefinedAbstr... impl impl operationImpl.... bridge operationImpl...
11
University of Twente Exercise-2Exercise-2 Find the meta-patterns in the Composite Pattern: Component{abstract} operation addComponent: removeComponent: getComponent: Composite operation addComponent: removeComponent: getComponent: components components do: [c | c operation. ] Client Leaf operation
12
University of Twente ConclusionsConclusions a framework should... vinclude a layer/part of domain knowledge that always applies. this part is fixed and requires no hooks! vdefine hook methods and hook components for extending this layer with application-specific behavior the hot spots... vadd domain knowledge by enforcing constraints on the (substituted) hooks by explicit checks & subtyping through interaction protocols vonly a few (OO) techniques for Template-Hook composition
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.