Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Design Pattern & UML  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [精华]
zyzhang

Explorer



发贴: 155
积分: 30
于 2004-09-01 22:37 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Opening Questions For A Study Group

Welcome to add your own questions and answers.
It's important to understand the spirit behind each pattern, instead of just focusing on the structure only.


Factory Method
How does Factory Method promote loosely coupled code?

Strategy
Part 1: What happens when a system has an explosion of Strategy objects? Is there some way to better manage these strategies?

Part 2: In the implementation section of this pattern, the authors describe two ways in which a strategy can get the information it needs to do its job. One way describes how a strategy object could get passed a reference to the context object, thereby giving it access to context data. But is it possible that the data required by the strategy will not be available from the context's interface? How could you remedy this potential problem?


Decorator
In the Implementation section of the Decorator Pattern, the authors write: A decorator object's interface must conform to the interface of the component it decorates.
Now consider an object A, that is decorated with an object B. Since object B "decorates" object A, object B shares an interface with object A. If some client is then passed an instance of this decorated object, and that method attempts to call a method in B that is not part of A's interface, does this mean that the object is no longer a Decorator, in the strict sense of the pattern? Furthermore, why is it important that a decorator object's interface conforms to the interface of the component. it decorates?


Composite
Part 1: How does the Composite pattern help to consolidate system-wide conditional logic?

Part 2: Would you use the composite pattern if you did not have a part-whole hierarchy? In other words, if only a few objects have children and almost everything else in your collection is a leaf (a leaf can have no children), would you still use the composite pattern to model these objects?


Iterator
Consider a composite that contains loan objects. The loan object interface contains a method called "AmountOfLoan()", which returns the current market value of a loan. Given a requirement to extract all loans above, below or in between a certain amount, would you write or use an Iterator to do this?

Template Method
The Template Method relies on inheritance. Would it be possible to get the same functionality of a Template Method, using object composition? What would some of the tradeoffs be?

Abstract Factory
In the Implementation section of this pattern, the authors discuss the idea of defining extensible factories. Since an Abstract Factory is composed of Factory Methods, and each Factory Method has only one signature, does this mean that the Factory Method can only create an object in one way?
Consider the MazeFactory example. The MazeFactory contains a method called MakeRoom, which takes as a parameter one integer, representing a room number. What happens if you would also like to specify the room's color & size? Would this mean that you would need to create a new Factory Method for your MazeFactory, allowing you to pass in room number, color and size to a second MakeRoom method?

Ofcourse, nothing would prevent you from setting the color and size of the Room object after is has been instantiated, but this could also clutter your code, especially if you are creating and configuring many objects. How could you retain the MazeFactory and keep only one MakeRoom method but also accomodate different numbers of parameters used by MakeRoom to both create and configure Room objects?


Builder
Like the Abstract Factory pattern, the Builder pattern requires that you define an interface, which will be used by clients to create complex objects in pieces. In the MazeBuilder example, there are BuildMaze(), BuildRoom() and BuildDoor() methods, along with a GetMaze() method. How does the Builder pattern allow one to add new methods to the Builder's interface, without having to change each and every sub-class of the Builder?

Singleton
The Singleton pattern is often paired with the Abstract Factory pattern. What other creational or non-creational patterns would you use with the Singleton pattern?

Proxy
If a Proxy is used to instantiate an object only when it is absolutely needed, does the Proxy simplify code?

Adapter
Would you ever create an Adapter that has the same interface as the object which it adapts? Would your Adapter then be a Proxy?

Bridge
How does a Bridge differ from a Strategy and a Strategy's Context?

Mediator
Since a Mediator becomes a repository for logic, can the code that implements this logic begin to get overly complex, possible resembling speggheti code? How could this potential problem be solved?

Observer
Part 1: The classic Model-View-Controller design is explained in Implementation note #8: Encapsulating complex update semantics. Would it ever make sense for an Observer (or View) to talk directly to the Subject (or Model)?

Part 2: What are the properties of a system that uses the Objserver pattern extensively? How would you approach the task of debugging code in such a system?

Part 3: Is it clear to you how you would handle concurrency problems with is pattern? Consider an Unregister() message being sent to a subject, just before the subject sends a Notify() message to the ChangeManager (or Controller).


Chain of Responsibility
Part 1: How does the Chain of Responsibility pattern differ from the Decorator pattern or from a linked list?.

Part 2: Is it helpful to look at patterns from a structural perspective? In other words, if you see how a set of patterns are the same in terms of how they are programmed, does that help you to understand when to apply them to a design?


Memento
The authors write that the "Caretaker" participant never operates on or examines the contents of a memento. Can you consider a case where a Caretaker would infact need to know the identity of a memento and thus need the ability to examine or query the contents of that memento? Would this break something in the pattern?

Command
In the Motivation section of the Command pattern, an application's menu system is described. An application has a Menu, which in turn has MenuItems, which in turn execute commands when they are clicked. What happens if the command needs some information about the application in order to do its job? How would the command have access to such information such that new comamnds could easily be written that would also have access to the information they need?

Prototype
Part 1: When should this creational pattern be used over the other creational patterns?
Part 2: Explain the difference between deep vs. shallow copy.


State
If something has only two to three states, is it overkill to use the State pattern?

Visitor
One issue with the Visitor pattern involces cyclicality. When you add a new Visitor, you must make changes to existing code. How would you work around this possible problem?

Flyweight
Part 1: What is a non-GUI example of a flyweight?
Part 2: What is the minimum configuration for using flyweight? Do you need to be working with thousands of objects, hundreds, tens?


Interpreter
As the note says in Known Uses, Interpreter is most often used "in compilers implemented in object-oriented languages...". What are other uses of Interpreter and how do they differ from simply reading in a stream of data and creating some structure to represent that data?

Facade
Part 1: How complex must a syb-system be in order to justify using a facade?

Part 2: What are the additional uses of a facade with respect to an organization of designers and developers with varying abilities? What are the political ramifications?


zyzhang edited on 2004-09-02 17:11

作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:zyzhang]
主管





发贴: 448
积分: 100
于 2004-11-06 12:11 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
good questions


作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:zyzhang]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2004-11-07 03:04 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Try to give your answer. This is a good discusion topics. Let's discuss it if you have time.

Thanks, zyzhang, where did you get it?



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:zyzhang]
主管





发贴: 448
积分: 100
于 2004-11-08 11:19 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Jedi floater, pls give your answer first Smile


作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:zyzhang]
floater

Java Jedi

总版主


发贴: 3233
积分: 421
于 2004-11-08 12:07 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
I'll try to find some time to answer them with my experience(which might be wrong).

Right now, I just have too many things to do, I completed a spring ibatis dao document, I need to polish that before sending it out to here. I am thinking about a tool for spring context, explore how far I could go(features we need, design, technical aspects, besides considering eclipse plugin and ju's jb plugin).

this is an interesting topic.



"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
- Martin Fowler, Refactoring - Improving the Design of Existing Code
作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:zyzhang]
主管





发贴: 448
积分: 100
于 2004-11-08 13:13 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
洗眼贡看 好戏上演

good idea, let's do it



作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:zyzhang]
主管





发贴: 448
积分: 100
于 2004-11-08 13:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
仔细看了看那些问题,有的提的还真尖锐,经验不足不好回答。恳请Jedi floater指示

主管 edited on 2004-11-08 19:14

作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:floater]
主管





发贴: 448
积分: 100
于 2004-11-08 17:12 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
floater wrote:

I am thinking about a tool for spring context, explore how far I could go(features we need, design, technical aspects, besides considering eclipse plugin and ju's jb plugin).

this is an interesting topic.


1、要有一个好用的xml editor来管理context
2、要能可视化的描述bean之间依赖关系



作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:zyzhang]
WeiterWay





发贴: 25
积分: 0
于 2004-11-24 14:08 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
这么好的题材,怎么没有过来人发表高见呀?

关于Observer模式,如何控制并发,应该采用哪种并发模式?
Part 3: Is it clear to you how you would handle concurrency problems with is pattern? Consider an Unregister() message being sent to a subject, just before the subject sends a Notify() message to the ChangeManager (or Controller).


WeiterWay edited on 2004-11-25 14:05

作者 Re:Open Questions for Design Patterns Study Group (Referened from DPSG-NYC) [Re:zyzhang]
zyzhang

Explorer



发贴: 155
积分: 30
于 2004-12-20 20:37 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Recently, I've been so busy on the projects and have little time on thinking over the answers to these quetions.

About the questions on the observer design pattern, we used to be challenged by these questions on the design of workflow engine. when implementing, it's real a bit of complex(Threading Control).

I think learning something new by asking yourself questions is a better way to go. hopefully, more people can join the disscusion.




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2018 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号
客服电话 0592-8750026    客服信箱 714923@qq.com    客服QQ 714923