生成基类和派生类层次结构的代码的模式名称?
我对这个设计模式的名称完全空白。
它有时与代码生成器一起使用,代码生成器创建基类和派生类的层次结构,其中每个级别的派生类都从基类继承,但基类从上一级的派生类继承(如果有的话)。也就是说,每一代中的继承链接不断在派生类和基类之间来回跳动。
该模式的结果是您可以手动修改派生类(然后永远不会重新生成),并且更改将反映在整个类层次结构中。好处是您可以重新生成基类并保留在任何派生类中所做的更改。
这是一个非常有用的模式,GraniteDS 的 GAS3 代码生成器就是一个很好的例子:
http://www.graniteds.org/confluence/display/DOC/3.+Gas3+Code+Generator
我曾经知道这种模式的名称,但我不记得了让我疯狂。 救命!!!
I am drawing a complete blank on the name of this design pattern.
It's sometimes used with code generators that create a hierarchy of base classes AND derived classes where at each level the derived inherits from the base, but the base inherits from the derived class one level up (if there is one). That is, the inheritance link in each generation keeps bouncing back and forth between derived and base classes.
The result of the pattern is that you can manually modify a derived class (which is then never re-generated) and the changes are reflected through the entire class hierarchy. The benefit being that you can regenerate the base classes and keep the changes made in any derived classes.
It's a tremendously useful pattern and a great example of this is the GAS3 code generator from GraniteDS:
http://www.graniteds.org/confluence/display/DOC/3.+Gas3+Code+Generator
I used to know the name of this pattern and the fact I can't recall is making me insane. HELP!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
卫生部——写下这个问题一定勾起了我的记忆。它称为“代沟”模式:
http://www.research.ibm .com/designpatterns/pubs/gg.html
DOH -- As it happened writing the question must have jogged my memory. It is called the "Generation Gap" pattern:
http://www.research.ibm.com/designpatterns/pubs/gg.html