java Java中的设计模式练习
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5134292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Design patterns exercise in Java
提问by duduamar
Hi I have an assignment to teach a team the subject of design principle. As a final exercise to this mini course, I thought to give them an exercise in design pattern, in Java. My idea is to give them a code written badly, and they should refactor it using several design patterns. I didn't find anything similar to that in my search (both in the web and in stack overflow).
嗨,我有一个任务要教一个团队设计原则的主题。作为这门迷你课程的最后一个练习,我想给他们一个 Java 设计模式练习。我的想法是给他们一个写得很糟糕的代码,他们应该使用几种设计模式重构它。我在搜索中没有找到任何类似的东西(在网络和堆栈溢出中)。
Any references to something similar to what I'm looking for?
任何对类似于我正在寻找的东西的引用?
Thanks
谢谢
回答by Nix
One of the best sites out there : http://www.industriallogic.com/xp/refactoring/catalog.html
最好的网站之一:http: //www.industriallogic.com/xp/refactoring/catalog.html
They basically show you code, and then the re-factored code. Its not going to be one big hopping pile of crap, but you can take an aggregate a couple and aggregate them together to form some ugly code, and then do the same to show the solution.
他们基本上向您展示代码,然后是重构的代码。它不会是一大堆废话,但是您可以将一对聚合在一起并将它们聚合在一起以形成一些丑陋的代码,然后执行相同的操作以显示解决方案。
回答by Thuy
You can check this book "Refactoring: Improving the Design of Existing Code" of Martin Fowler. It contains examples of "smell" coding and provide solution to refactor it.
您可以查看 Martin Fowler 的这本书“重构:改进现有代码的设计”。它包含“气味”编码的示例并提供重构它的解决方案。
回答by Don Roby
This has alot of code filling the bill. The author, Joshua Kerievsky, is also the founder of Industrial Logic, which has (as Nix noted in his response) good material on this topic, drawn from and augmenting this book.
这有很多代码填写账单。作者 Joshua Kerievsky 也是Industrial Logic的创始人,该公司(正如 Nix 在他的回应中指出的那样)有关于这个主题的很好的材料,这些材料来自本书并对其进行了补充。