What are the best resources for design patterns an

2019-03-14 07:01发布

When it comes to the use of design patterns, I am guessing there are three types of shops. Those who wouldn't know a pattern if it hit them in the face - these usually prefer the Ctrl-C / Ctrl-V approach to code-reuse. Those who spend hours a day searching their legacy code in hopes of implementing one more great pattern - these usually spend more time refactoring the code of simple programs than would ever be spent in a hundred years of maintenance. And finally, those who walk the middle path using patterns when they make sense, and coding whatever comes first for minimally exposed code.

I'm wondering if anyone has locked down a good approach to a balanced incorporation of pattern use in the software development life cycle. Also, what is the best resource on the Web for patterns, their motivating factors, and their proper use?

Thanks.

13条回答
聊天终结者
2楼-- · 2019-03-14 07:57

I think the best web resource containing information about patterns and refactoring - http://sourcemaking.com

查看更多
不美不萌又怎样
4楼-- · 2019-03-14 07:59

Everyone's using patterns all the time. They just might not know it. Even a simple thing like 'iterate over a list' is a pattern.

I think the best way to incorporate patterns into your work cycle, is just to use them, and to refer to them by name when discussing them and when commenting your code. Hopefully, this will result in a spread of knowledge.

So, say for example, you've spotted that what your doing is a great fit for Observer. You say to your colleague "Hey, this will be really easy to do if we make this object an Observer, and this object its subject."

Either your colleague will understand right away -- that's patterns saving you time -- or you get to educate them, and next time you mention Observer they'll understand right away.

And at the same time, you're spreading the knowledge, and they'll spot opportunities to use the new patterns they've learned from you. This goes both ways of course. Next time it might be them teaching you a new pattern.

All of this does rely on your colleague not being the type who nods and pretends to understand something when they don't. You do need them to say "Hey, you mentioned Observer, I don't think I know what that is."

查看更多
冷血范
5楼-- · 2019-03-14 07:59

I am a big fan of the series and have read many of their books, so I'd recommend Head First Design Patterns. You can read it online via O'Reilly's Safari Bookshelf, but the hard copy comes with a great patterns poster too.

查看更多
神经病院院长
6楼-- · 2019-03-14 08:03

The use of "pattern" depends to a high degree from

  1. the language used
  2. goals one like to achive.

Design pattern can be named overrated in languages like C++, Java and the like. They hide the inflexibility introduces with all kinds of typing issues. Here's a link on what pattern "survive" in less restrictive languages: http://norvig.com/design-patterns/

Another example is the aspect oriented programmming, in which with might effort things are "introduced" in a language not "designed" for it.

The philosophy behind the used tools has a big influence also. Just compare let's say average PHP or Visual Basic programs and solutions in Smalltalk, Common Lisp,Haskell and the like.

The syntax elements have a big impact also. You'll see tons of similar loops let's say in C, C++ (iterators) but if you'd look into languags which support for higher order functions you'll just find a few loops.

You then have to see which way people do access programming, bottom up or top down, piecemeal growth or building pyramides, or any other individual preferences

I suggest reading the mentioned link, and then check implementations in "different" languages....

Regards Friedrich

查看更多
可以哭但决不认输i
7楼-- · 2019-03-14 08:03

I agree with these references, but there are not newbie friendly. To quick start learning design patterns the easy way :

Head First : design pattern

Then your can check the more advanced books once you got the big picture (a lot of practical examples ;-))

查看更多
登录 后发表回答