由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - No design patterns are necessary. In any language. - Jan Hudec
相关主题
快速系统学习 c++ design pattern有什么好书或者网站吗design patterns到底有用吗?
Which is next book after "Effective C++"?请教template和factory有啥区别?
multithread program design pattern (C++)也问个STL的问题, 谢谢
问问关于 OO Design, Design Pattern 方面的书c++里的函数可不可以是virtual+static
求推荐讲OO Design的书紧急求助—寻C++ tutor
大部份 design pattern 是不需要的学习design pattern 看哪本书比较好?
经典的Design Pattern in Java的书/资料两道Java面试问题
How many people use design patterns when coding?关于pattern design的那本非常经典的书是什么?谁写的?
相关话题的讨论汇总
话题: patterns话题: design话题: jan话题: hudec话题: any
进入Programming版参与讨论
1 (共1页)
t**r
发帖数: 3428
1
No design patterns are necessary. In any language.
I tend to come across a lot of code written by people who read up on design
patterns and than think they should use them all over the place and the
result is the actual code gets buried under tons of interfaces, wrappers and
layers and pretty hard to read. That's a wrong approach to design patterns.
Design patterns exist so that you have a repertoire of useful idioms handy
when you come across a problem. But you should never apply any pattern
before you identify the problem. Keep It Simple Stupid should always be the
superior governing principle.
It also helps to think of design patterns as a concept to think about the
problem rather than specific boilerplate code to write. And about much of
the boilerplate as workaround to Java lacking free functions and standard
function objects that you use in most other languages that have them (like
Python, C#, C++ etc).
I might say that I have a visitor pattern, but in any language with first
class functions it will be just function taking function. Instead of factory
class I usually have just factory function. I might say I have interface,
but than it's just a couple of methods marked with comment, because there
wouldn't be any other implementation (of course in python interface is
always just comment, because it's duck-typed). I still speak of the code as
using the pattern, because it's useful way to think about it, but don't
actually type in all the stuff until I really need it.
So learn all the patterns as concepts. And forget the specific
implementations. The implementation varies, and should vary, in real world
even in Java.
Jan Hudec
d*******r
发帖数: 3299
2
大部分同意
w***g
发帖数: 5958
3
打架的时候谁会记着一招一式叫什么名字。

design
and
patterns.
the

【在 t**r 的大作中提到】
: No design patterns are necessary. In any language.
: I tend to come across a lot of code written by people who read up on design
: patterns and than think they should use them all over the place and the
: result is the actual code gets buried under tons of interfaces, wrappers and
: layers and pretty hard to read. That's a wrong approach to design patterns.
: Design patterns exist so that you have a repertoire of useful idioms handy
: when you come across a problem. But you should never apply any pattern
: before you identify the problem. Keep It Simple Stupid should always be the
: superior governing principle.
: It also helps to think of design patterns as a concept to think about the

1 (共1页)
进入Programming版参与讨论
相关主题
关于pattern design的那本非常经典的书是什么?谁写的?求推荐讲OO Design的书
讲design pattern的哪本书最好?大部份 design pattern 是不需要的
刚到head first的design pattern经典的Design Pattern in Java的书/资料
[合集] 问一个design pattern的问题How many people use design patterns when coding?
快速系统学习 c++ design pattern有什么好书或者网站吗design patterns到底有用吗?
Which is next book after "Effective C++"?请教template和factory有啥区别?
multithread program design pattern (C++)也问个STL的问题, 谢谢
问问关于 OO Design, Design Pattern 方面的书c++里的函数可不可以是virtual+static
相关话题的讨论汇总
话题: patterns话题: design话题: jan话题: hudec话题: any