This is part of the java AWT package: http://i.imgur.com/e3LVgUO.png

  • It looks like container is a decorator pattern, where container is the decorator, the panel and window subclasses are concrete decorators, the decorator has a pointer to component, and the textField & textArea are concrete components.

  • another one I think would be the template method pattern, between TextComponent, TextField, and TextArea

  • I want to say that LayoutManager is an abstract factory, but I am not 100% sure. LayoutManager is the interface that defines different layouts which are pushed onto the Component.. maybe observer pattern?

I what I think correct? apparently there are others too, however I can't find what they are

有帮助吗?

解决方案

LayoutManagers are the Strategy Pattern. I don't see how a container is a Decorator. If anything I would think it would be a Composite but it doesn't look like that either. A Decorator is an impostor: it presents itself as another type and then augments the original.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top