人们如何决定他所使用的技术的设计模式?

发布于 2024-10-13 15:28:07 字数 1432 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

失而复得 2024-10-20 15:28:07

来自Head First - 设计模式

设计模式不会直接进入你的代码,它们首先进入你的大脑。一旦你的大脑充满了良好的模式应用知识,你就可以开始将它们应用到你的新设计中,并在你发现旧代码退化成一团死气沉沉、混乱不堪的丛林意大利面条代码时重新编写它。

首先查看项目,考虑适合现实世界需求的顶层设计。 然后(当你的大脑充满模式时)你将看到设计中的模式,并且知道要使用哪些模式。

请不要围绕美丽的图案构建您的设计。但有一个例外:您提到的技术带有一些最佳实践模式。您应该了解它们并使用它们(无论如何,它们中的大多数都是在框架中构建的,您无法避免使用它们)。对于那些你应该了解并使用它们的人,因为其他人在看到基于 spring、JPA、J2EE 的设计时期望这些模式......

A short quote from Head First - Design Patterns:

Design patterns don't go directly into your code, they first go into your BRAIN. Once you've loaded your brain with a good working knowledge of patterns, you can start to apply them to your new designs, and rework your old code when you find it's degrading into an inflexible mess of jungle spaghetti code.

First look at the project, think of a top-level design that fits the real world requirements. Then (with your brain loaded with patterns) you'll see the patterns inside the design and will know which patterns to use.

Please, don't build your design around beautiful patterns. With one exception: The technology, you've mentioned, comes with some best practice patterns. You should know them and use them (most of them are build in the frameworks anyway and you can't avoid using them). For those you should know and use them, because others expect those patterns when the see a design based on spring, JPA, J2EE, ...

金兰素衣 2024-10-20 15:28:07

应用设计模式是个人经验的问题,在某种程度上也是风格和偏好的问题。只需要练习就可以学习它,知识没有捷径,抱歉:-) 当然,书籍和其他人的故事是很好的信息来源 - 但仅此而已。您需要了解如何以及何时应用所有这些信息。最好的学习经验就是自己的错误,所以不要害怕犯错误。

如果您想收集战争故事,您可能想在programmers.stackexchange.com上询问。

Applying design patterns is a question of personal experience, and to some extent style and preference too. It just takes practice to learn it, there are no fast lanes to the knowledge, sorry :-) Of course, books and stories from others are a good source of information - but only that. You need to learn how and when to apply all that information. The best learning experiences are one's own mistakes, so don't fear of making mistakes.

If you want to collect war stories though, you may want to ask this on programmers.stackexchange.com.

弱骨蛰伏 2024-10-20 15:28:07

教程和手册中明确定义了这些技术的集成模式。确实没有太多的空间进行大的改变。查看以下链接以获取理解:

http:// /static.springsource.org/spring/docs/3.0.x/reference/orm.html

http://static.springsource.org/spring/docs/3.0.x/reference/web-integration.html#struts

一旦你使用所描述的技术完成所有集成,您可以稍微使用它以使其更适合您的目的。

他们自己正在推动这些技术使用某些模式。查看这些问题以了解更多详细信息:

什么设计Spring 框架中使用了哪些模式?

Hibernate 遵循哪种模式?

以及正如已经提到的,应用设计模式是一个经验和大脑的问题;)它迟早会到来。

Patters for integration these technologies are well defined in tutorials and manuals. There is really no much space for big changes. Have a look at following links to get an understanding:

http://static.springsource.org/spring/docs/3.0.x/reference/orm.html

http://static.springsource.org/spring/docs/3.0.x/reference/web-integration.html#struts

As soon as you have done all integration using described techniques, you may play with it a little bit to make it more suitable specifically for your purposes.

These technologies their self are pushing to to use some set of patterns. Have a look at these questions for more details:

What design patterns are used in Spring framework?

Which pattern does Hibernate follow?

And as already mentioned, applying design patterns is a matter of experience and brain ;) It will just come sooner or later.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文