Title: Generation Gap By Kurt Rehwinkel
1Generation GapByKurt Rehwinkel
2Generation Gap
- Introduction What is the Generation Gap?
- The author describes it as a pattern.
- It is potentially as much a strategy as much as a
pattern
3Generation Gap Intent
- Support for auto-generation and regeneration of
source code by software development tools. - To modify or extend generated code such that the
regeneration of the source does not effect the
implementation.
4Generation Gap Applicability
- Code is generated automatically.
- Generated code is encapsulated.
- Regenerated code retains form in interface and
instance variables. - Generated classes do not tend to be integrated
into inheritance hierarchies. To do so requires
the ability to specify super-classes and may
require multiple inheritance support in the
language.
5Generation Gap Participants
- CoreClass
- Abstract class containing tool generated
implementation. - Never modified by hand.
- Written and/overwritten by the software
development tool. - ExtensionClass
- A trivial subclass of CoreClass.
- Provides concrete implementations and extends or
overrides the behavior in the CoreClass. - Preserves developer generated software
implementations. - Client
- Instantiates and refers ONLY to ExtensionClass.
6Generation Gap Structure
7Generation Gap Example
class Clock public Clock_core public
Clock(const char) void Run()
virtual void SetTime() virtual void
SetAlarm() virtual void Snooze()
virtual void Update() private void
GetSystemTime(int h, int m, int s) void
SetSystemTime(int h, int m, int s) void
Alarm() private float _time
float _alarm
- class Clock_core
- public
- Clock_core(const char)
- protected
- Interactor Interior()
- virtual void SetTime()
- virtual void SetAlarm()
- virtual void Snooze()
- protected
- Picture _clock
- SF_Polygon _hour_hand
- SF_Rect _min_hand
- Line _sec_hand
-
8Generation Gap Consequences
- The Good
- Modifications/Implementations are decoupled from
generated code. - CoreClass and ExtensionClass may be developed and
tested independantly. - The Bad
- Doubles the number of classes.
- Changes to interfaces in the tool must be
reflected in the Extension. - The Ugly
- Integration into inheritance may be difficult.
9Generation Gap Related Pattern
- Use of other patterns such as Template Method,
Factory methods, or Strategy Patterns may serve
to make generated code more flexible and reusable.