1 / 9

Generation Gap By Kurt Rehwinkel

Generation Gap By Kurt Rehwinkel. Generation 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. Generation Gap: Intent.

dominique
Télécharger la présentation

Generation Gap By Kurt Rehwinkel

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Generation GapByKurt Rehwinkel

  2. Generation 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

  3. Generation 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.

  4. Generation 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.

  5. Generation 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.

  6. Generation Gap: Structure

  7. Generation 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; };

  8. Generation 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.

  9. Generation 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.

More Related