我应该是第一位的 - 设计模式或code? [英] What should come first -- the design pattern or the code?

查看:170
本文介绍了我应该是第一位的 - 设计模式或code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始一个新的新项目 - 我应该看看我的规格,并决定要应用的设计模式,或者只是想出了组织的总体思路,并允许模式,以通过重构有机冒出

在您的经验,哪些技术将是最有成效的,具有领先的清洁优雅code的机会更大?

我也想知道,如果有设计模式在那里,不被定义GoF的,但可能是一样有价值?如果是这样,什么是一些有用的资源为自己通知这些?


解决方案

您应该增加您的code有机结合,应用模式,因为他们适合。有图案太早匹配最多可导致很多不恰当的code和设计变得模糊抽象这么多的层。证人的code,你已经看到了写之后有人发现首次图案; - )

I'm starting on a fresh new project--should I look at my spec and decide which design patterns to apply, or just come up with a general idea of organization and allow the patterns to emerge organically through refactoring?

In your experience, which technique will be most productive and have a greater chance of leading to clean elegant code?

I'm also wondering if there are design patterns out there that aren't defined by the GoF, but could be just as valuable? If so, what are some useful resources for informing myself about these?

解决方案

You should grow your code organically, applying patterns as they fit. Matching up with patterns too early can lead to a lot of inappropriate code and so many layers of abstraction that the design becomes obfuscated. Witness any code you've seen that was written right after someone had discovered patterns for the first time ;-)

这篇关于我应该是第一位的 - 设计模式或code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆