Duplicate:
Learning implementing design patterns for newbies
学习实施新手的设计模式
I have been a developer for years and have my way of developing and have always kept up with the latest techologies. I want to start using a design pattern in the hope it will improve my development speed but I need to find one to apply and I need to find a full open source sample that demonstrates it.
我多年来一直是开发人员,并且有自己的开发方式,并始终跟上最新的技术。我想开始使用设计模式,希望它能提高我的开发速度,但我需要找到一个应用,我需要找到一个完整的开源示例来演示它。
I use and have an application that uses LINQ to SQL and .net 3.5 I tried to apply the repository pattern but found the structure complex and having to hack my way through it.
我使用并拥有一个使用LINQ to SQL和.net 3.5的应用程序我尝试应用存储库模式但发现结构复杂并且不得不破解我的方式。
Any advice for someone who wants to better their programming style?
对于想要改进编程风格的人有什么建议吗?
5 个解决方案
#1
Read blogs (RSS Feeds are prime). Read magazines. Read random MSDN entries. Write little trial applications. The only way to keep up is to discover it and practice it.
阅读博客(RSS Feed是主要的)。阅读杂志。读随机MSDN条目。写一点试用申请。跟上的唯一方法就是发现并实践它。
#2
Patterns aren't really "tech" in the traditional sense. Using patterns means applying your specific knowledge of a domain to a problem keeping in mind the patterns which apply to that domain. They are useful to exactly the extent that you have a base of experience to put them in context.
模式并不是传统意义上的“技术”。使用模式意味着将您对域的特定知识应用于问题,同时牢记适用于该域的模式。它们对于您具有将其置于上下文中的经验基础的程度非常有用。
The repository pattern, for example, is maybe not the best starting place for constructing a database architecture based on a pattern. Have you got a simpler pattern implemented such as Table Module or (in the specific case of data access) Active Record? If not then perhaps you should start there. These patterns focus on a fairly limited, basic way of organizing data and operations. Repository is more like a meta-pattern that then builds on top of these patterns, organizing a complex domain-data boundary into a simpler collection-like interface.
例如,存储库模式可能不是基于模式构建数据库体系结构的最佳起始位置。您是否实现了更简单的模式,如表模块或(在特定的数据访问情况下)Active Record?如果没有那么也许你应该从那里开始。这些模式侧重于组织数据和操作的相当有限的基本方式。存储库更像是一个元模式,然后构建在这些模式之上,将复杂的域数据边界组织成更简单的类似集合的接口。
#3
Two books that I would suggest reading are:
我建议阅读的两本书是:
Refactoring: Improving the Design of Existing Code (ISBN: 0-201-48567-2) and Refactoring To Patterns (ISBN: 0-321-21335-1)
重构:改进现有规范的设计(ISBN:0-201-48567-2)和重构模式(ISBN:0-321-21335-1)
Both are great books that will help you, at a high level, understand the when's and why's to applying patterns to your code. In addition, they are great reference material for some of the most commonly used patterns out there.
两本都是很好的书,可以帮助您在较高的层次上了解何时以及为什么要将模式应用于您的代码。此外,它们是一些最常用模式的很好的参考材料。
To be clear, these books are by no means the "complete library" of design patterns.
需要明确的是,这些书籍绝不是设计模式的“完整库”。
#4
My simple advice for bettering your programming style:
我提出的改进编程风格的简单建议:
- Pick a technology that you find productive and "fun" and keep with it to learn how to fully explore it's potential.
- Don't try to learn all the new technologies all the time - just keep yourself oriented.
- Seek advice and solutions where and when you actually need them - don't waste time learning solutions to problems you don't (yet) have.
- Regarding design patterns... Well... I'll probably get shot for this, but I don't really like the idea of cramming them all into my head "just in case". They are really a cooking book of "good solutions" for common problems. My advice here is: Whenever you run into problems that you can't come up with an obvious/immediate solution for - use them as reference.
- Learn from your mistakes (you'll make them).
- Don't marry your code. Throw away and rewrite is an excellent way of bettering the style.
选择一种您发现高效且“有趣”的技术,并与之保持一致,以学习如何充分发掘它的潜力。
不要试图一直学习所有新技术 - 只要保持自己的导向。
在您实际需要的地方和时间寻求建议和解决方案 - 不要浪费时间学习解决方案,解决您尚未解决的问题。
关于设计模式......好吧......我可能会为此拍摄,但我真的不喜欢将它们全部塞进我脑中的想法“以防万一”。它们实际上是针对常见问题的“好解决方案”的烹饪书。我的建议是:每当遇到问题而你无法提出明显/即时的解决方案时 - 使用它们作为参考。
从错误中学习(你会做出来的)。
不要嫁给你的代码。丢掉并重写是改善风格的绝佳方式。
#5
I would sincerely recommend dofactory.com
我真诚地推荐dofactory.com
which also offers code examples in vb.net + c# for all the design patterns
它还为vb.net + c#提供了所有设计模式的代码示例
#1
Read blogs (RSS Feeds are prime). Read magazines. Read random MSDN entries. Write little trial applications. The only way to keep up is to discover it and practice it.
阅读博客(RSS Feed是主要的)。阅读杂志。读随机MSDN条目。写一点试用申请。跟上的唯一方法就是发现并实践它。
#2
Patterns aren't really "tech" in the traditional sense. Using patterns means applying your specific knowledge of a domain to a problem keeping in mind the patterns which apply to that domain. They are useful to exactly the extent that you have a base of experience to put them in context.
模式并不是传统意义上的“技术”。使用模式意味着将您对域的特定知识应用于问题,同时牢记适用于该域的模式。它们对于您具有将其置于上下文中的经验基础的程度非常有用。
The repository pattern, for example, is maybe not the best starting place for constructing a database architecture based on a pattern. Have you got a simpler pattern implemented such as Table Module or (in the specific case of data access) Active Record? If not then perhaps you should start there. These patterns focus on a fairly limited, basic way of organizing data and operations. Repository is more like a meta-pattern that then builds on top of these patterns, organizing a complex domain-data boundary into a simpler collection-like interface.
例如,存储库模式可能不是基于模式构建数据库体系结构的最佳起始位置。您是否实现了更简单的模式,如表模块或(在特定的数据访问情况下)Active Record?如果没有那么也许你应该从那里开始。这些模式侧重于组织数据和操作的相当有限的基本方式。存储库更像是一个元模式,然后构建在这些模式之上,将复杂的域数据边界组织成更简单的类似集合的接口。
#3
Two books that I would suggest reading are:
我建议阅读的两本书是:
Refactoring: Improving the Design of Existing Code (ISBN: 0-201-48567-2) and Refactoring To Patterns (ISBN: 0-321-21335-1)
重构:改进现有规范的设计(ISBN:0-201-48567-2)和重构模式(ISBN:0-321-21335-1)
Both are great books that will help you, at a high level, understand the when's and why's to applying patterns to your code. In addition, they are great reference material for some of the most commonly used patterns out there.
两本都是很好的书,可以帮助您在较高的层次上了解何时以及为什么要将模式应用于您的代码。此外,它们是一些最常用模式的很好的参考材料。
To be clear, these books are by no means the "complete library" of design patterns.
需要明确的是,这些书籍绝不是设计模式的“完整库”。
#4
My simple advice for bettering your programming style:
我提出的改进编程风格的简单建议:
- Pick a technology that you find productive and "fun" and keep with it to learn how to fully explore it's potential.
- Don't try to learn all the new technologies all the time - just keep yourself oriented.
- Seek advice and solutions where and when you actually need them - don't waste time learning solutions to problems you don't (yet) have.
- Regarding design patterns... Well... I'll probably get shot for this, but I don't really like the idea of cramming them all into my head "just in case". They are really a cooking book of "good solutions" for common problems. My advice here is: Whenever you run into problems that you can't come up with an obvious/immediate solution for - use them as reference.
- Learn from your mistakes (you'll make them).
- Don't marry your code. Throw away and rewrite is an excellent way of bettering the style.
选择一种您发现高效且“有趣”的技术,并与之保持一致,以学习如何充分发掘它的潜力。
不要试图一直学习所有新技术 - 只要保持自己的导向。
在您实际需要的地方和时间寻求建议和解决方案 - 不要浪费时间学习解决方案,解决您尚未解决的问题。
关于设计模式......好吧......我可能会为此拍摄,但我真的不喜欢将它们全部塞进我脑中的想法“以防万一”。它们实际上是针对常见问题的“好解决方案”的烹饪书。我的建议是:每当遇到问题而你无法提出明显/即时的解决方案时 - 使用它们作为参考。
从错误中学习(你会做出来的)。
不要嫁给你的代码。丢掉并重写是改善风格的绝佳方式。
#5
I would sincerely recommend dofactory.com
我真诚地推荐dofactory.com
which also offers code examples in vb.net + c# for all the design patterns
它还为vb.net + c#提供了所有设计模式的代码示例