-
Notifications
You must be signed in to change notification settings - Fork 0
How to build a framework
Muriele Trentini edited this page Jan 31, 2018
·
11 revisions
- Article: Java Framework Design
- Building a Framework
- Artikel: A ”Framework” for Object Oriented Frameworks Design
- Book: Framework Design Guidelines
- frozen spot to denote a common (or shared) aspect of the family
- hot spot to denote a variable aspect of the family
- frozen spots
- set of abstract and concrete base classes that collaborate in some structure
- common behaviour
- implemented by a fixed, concrete template method in a baseclass
- hot spots
- represented by a group of abstract hook methods
- template method calls a hook method to invoke a function that is specific to one family member
- hot spot is realized in a framework as a hot spot subsystem
- consists of an abstract base class, concrete subclasses of that base class, and perhaps other related classes
- two principles for framework construction
- unification principle
- inheritance to implement hot spot subsystem
- template methods and hook methods in same abstract base class.
- hook methods are implemented in subclasses of the base class.
- separation principle
- delegation to implement hot spot subsystem
- template methods in concrete context class
- hook methods in separate abstract class and implemented in its subclasses
- unification principle
- useful patterns
- Template Method
- uses unification principle
- Strategy pattern
- uses separation principle
- Template Method
- which principle to choose
- An application of a framework that uses the separation principle may execute slightly less efficiently than a unification-based framework, but separation may enable the application to adapt itself at runtime by merely changing object references
- inversion of control
- its template methods “call down” to the client-supplied hook methods
During framework-based application development, users fall into four categories or roles:
- framework developer
- build framework 'backbone'
- component developer
- builds new components and integrates them in the framework
- application developer
- assembles components into a custom application
- end user
- uses the application
- control visibility to keep published parts of the Framework small
- use Interfaces
- provide well-divined "hook points" that permit extensibility in places where you intend it to occur
- prevent extension in all other places