kukooBlog
look to the master, follow the master, walk with the master, see through the master, become the master.

August 28, 2005

Top 5 Principles of Enterprise Architecture

Posted @ 3:12 am+8 in Programming, Patterns | Licensed under a Creative Commons License

上周在Colorado,Martin Fowler 和 Bruce Eckel 邀请了一些“大腕”级的人物,如Rod Johnson,Floyd Marinescu等,开了一个“座谈会”(现场的一些照片在这里)。 其中讨论到:“企业级架构最关键的原则问题是什么”。 这些“大腕”一共总结出来40条,然后投票得出了最关键的5条 (Top 5 Principles of Enterprise Architecture):

  1. Use a layered architecture.
  2. Build Automated Regression Tests, which was tied with:
  3. Manage your application as you would a software product. eg: frequent and numbered releases, same rigor as a product.
  4. Use the smallest team you possibly can tied with:
  5. Attack the domain problem first (or - work on your domain model before other parts of the app).

与之对应的Top Bottom 5则是(从后往前):

  1. Use Model Driven Architecture.
  2. Determine all your requirements upfront.

    and a three way tie between: (最后3个并列)
  3. Use EJBs.
  4. Prefer web based UI’s.
  5. Prefer open source projects.

Floyd Marinescu关于这次“研讨会”更详细的blog

Yourit Technorati cosmos Refresh Technorati

June 26, 2005

Patterns and Practice [Erich Gamma]

Posted @ 9:22 am+8 in Programming, Patterns | Licensed under a Creative Commons License

这是Artima Developer的总编 Bill Venners对Erich Gamma的采访中的第四部分。在前三部分中,Bill和Erich讨论了如何思考和使用Design Pattern灵活性以及可重用性如何对Interface编程以及使用使用object composition而不是类继承

在第四部分中,Bill和Erich讨论了设计模式如何与解决问题相配对,设计模式如何帮助你理解问题解决得意图,以及如何通过练习成为一个好的设计师。

[Update: 一些心得]:

如何成为一个好的设计师?理解这些设计模式是不够的,仅仅只读完了GoF这本书也是不够的。还需要做甚呢?你需要练习,需要看代码,看其它好的设计师是如何设计系统的。

In addition to reading books, you need to read and understand lots of code, see how existing systems solve a particular problem and what experienced designers did. Basically what design patterns do is to tell you what these developers have done. But, just reading about it isn’t enough. You become a master by mimicking the work of excellent developers. ….. Not only do you learn about a particular development process you will also learn how to communicate about a design in a group of developers. As a good designer you not only come up with good designs you also communicate and defend them. You have to practice, like an apprentice in a way. Over time you’ll become as experienced as experienced designers.

作为一个新手,就算理解了GoF中的所有设计模式,也还是不够的,重要的,要知道,在什么时候,什么情况下,使用什么样的patterns。 而这往往是非常难的。 通常只有完成了之后,仔细思考自己的设计和代码的时候才会发现需要使用某个模式,或者某一种模式使用错了。 这个时候,就需要使用“重构”技术,来应用你觉得正确的模式。 只有练习再练习。

记住这句话:look to the master, follow the master, walk with the master, see through the master, become the master…


第一部分
第二部分
第三部分

Yourit Technorati cosmos Refresh Technorati

Design Principles from Design Patterns [Erich Gamma]

Posted @ 8:38 am+8 in Programming, Patterns | Licensed under a Creative Commons License

这是Artima Developer的总编 Bill Venners对Erich Gamma的采访中的第三部分。Bill 和 Erich 讨论了设计模式中的两个原则:对接口编程(program to an interface), 使用object composition而不是类继承。 在前两部分中,Bill和Erich讨论了如何思考和使用Design Pattern灵活性以及可重用性

[读后的一些心得]:

Erich第三部分中谈到,他希望支持Eclipse的整个社群,可以维持10到20年的生命期(“We always keep in mind as we design Eclipse that it has to last ten or twenty years. ….. I really mean that Eclipse should still be able to support an active community in ten or twenty years. ”),甚至更长(虽让他不敢奢望Eclipse社群会像埃及的金字塔一样保存上千年)。这种想法,现在确实已经非常普遍了,就连Sun的首席执行官Jonathan Schwartz也认为,“you can compete against a product, but it’s close to impossible to compete against a community. (和一个产品竞争容易,但是和一个社群竞争几乎接近不可能)”(Ecology, Communities and Platform Adoption)。所以,Sun也在不断的培养Solaris和Netbean的开发和使用者的社群。

Eclipse需要保持竞争力,关键也在于开发和使用者的这个社团。 Eclipse的plug-in架构,已经保证了这个社群会很快的成长(因为会有大量的开发者去写plug-in),大公司(如IBM,BEA,Borland)的加入和支持,也扩大了Eclipse的知名度,使得更多的开发者加入进去。 但是如何更好的融合这个社群,如何保证Eclipse的核心基础架构不受外部的困惑(变得更加庞大,或者臃肿)但又会不断创新,如何协调好Eclipse和其他Eclipse.org下面的顶级项目(如BIRT,WTP,AspectJ等)的整合关系,这些,确实也值得思考。

对interface编程,这个似乎是个老生常谈的问题了,但是却从来没有思考过,这种编程方式会影响到这个开发团队的协同工作,特别是一个超过10人的开发团队,而对一个分布在不同地方的开发团队(比如项目外包以后,不同的开发小组位于不同的城市,甚至国家),这种编程方式带来的影响更大。

为什么会这样呢? 在一个只有3-4人的开发团队里面,任何的改动,可以快速的通知其他的人,而且,现在IDE中的重构工具会解决大部分的工作。 但是,当一个开发团队变大的时候,通常就会分成小组,不同的小组对不同的部分负责。 在这种情况下,你在自己的模块中发布了API,你就必须确保这个API是稳定的。

“Once you have published an API then it is your responsibility to keep them stable. Otherwise you will break the other components and nobody is able to make progress. Having stable APIs is a key to making progress in a project of this size.”

所以这是一个是否把API发布以及发布了以后如何维护的问题:“So it’s the difference, as Martin Fowler would say, between public and published. Something can be public, but that doesn’t mean you have published it. ”即使定义了API,公开发布(publish)和这个API是公共的(public)是有区别的:API公开发布以后,就需要非常的小心,因为任何的API改动都可能会破坏其他在使用这个API的代码。


第一部分
第二部分

Yourit Technorati cosmos Refresh Technorati

灵活性和可重用 [Eric Gamma]

Posted @ 8:27 am+8 in Programming, Patterns | Licensed under a Creative Commons License

这是Artima Developer的总编Bill Venners对Erich Gamma的采访中的第二部分,Bill 和 Eric 讨论了重用性的重要性 (importance of reusability)。

重用的最高境界是什么?我们创建一个非常高层的,面向具体应用的框架,然后只要做简答的客户化,并且重用这个框架中现有的设计。(“We thought the way to create software was to build high-level, domain-specific frameworks, and then you just customize them and reuse all the design that is codified into them. That was the reuse nirvana.”)但是,连Eric都意识到,这太理想化了,因为 “I have learned that it’s hard to create highly reusable frameworks.”

在谈到可重用的framework的时候,Eric提到了Eclipse:

“A good example of how I like to see reuse at work is Eclipse. It’s built of components we call plug-ins. A plug-in bundles your code and there is a separate manifest where you define which other plug-ins you extend and which points of extension your plug-in offers. Plug-ins provide reusable code following explicit conventions to separate API from internal code. The Eclipse component model is simple and consistent too. It has this kernel characteristic. Eclipse has a small kernel, and everything is done the same way via extension points. The combination of a component model and the focus on APIs is one of the key ingredients of Eclipse. Controlled extensibility is another important one. (Eclipse是构构建在我们称之为plug-in的组件上面的。一个plug-in含有你的代码,而且详细定义了你从哪些其他的plug-in扩展而来,以及你的plug-in提供了哪些扩展点给别人使用。Plug-in提供了可重用的代码,而且遵循将API和内部的代码分离开。同时,Eclipse的组件模式简单而且一致。Eclipse只有一个很小的核心,所有其他的都市通过扩展点这种同样的方式来做的。Eclipse中的一个重要组成部分就是组件模型和面向API的方式的结合。另一个重要点则是受到控制的扩展性。)”

那么,什么又是Controlled extensibility呢?为什么要对扩展性进行控制呢?

“You can go and expose everything, and people can change anything. The original Smalltalks had some of this flavor. The problems start when the next version comes along. If you have exposed everything, you cannot change anything or you break all your clients. …
Also when you study the Eclipse API you will find that we go further than just specifying which classes are published API. The Eclipse API also specifies whether a class is intended to be subclassed. (你可以把一切都公布出来,SmallTalk就是这样做的。但是,当下一个版本出来的时候,可能就会碰到问题。如果你公布了一切,那么你就不能做改动了,活着你可能会破坏你的客户端使用的东西….在Eclipse里面,我们不仅仅定义了哪些类是公开的API,我们处理得更深层次,我们甚至定义了哪些API是可以被扩展的,哪些不可以。”

Eric对于重用,定义了三个级别:最低一级,重用类(classes);最高一级,框架(framework);而中间一级,就是设计模式(Design Pattern)

“This is where I see patterns. Design patterns are both smaller and more abstract than frameworks. They’re really a description about how a couple of classes can relate to each other and interact with each other. The level of reuse increases when you move from classes to patterns and finally frameworks. ”

Eric提到了一个有趣的现象。通常,我们拿到一个需求,会先做设计,做设计的时候,我们会使用设计模式(Design Pattern)。但是,使用XP (eXtreme Programming)方式的人不这样做,他们先写测试(“They write a test”)。

那么,设计一个framework的时候,要注意什么呢?要避免frameworkitis.

“Frameworks abstract and provide higher level default functionality. To do so the framework needs to be in control. This loss of control can lead to what is sometimes called frameworkitis. ”

Frameworkitis就是说,一个framework想要做的东西太多,或者它并不是按照你设想的做的而你又不能去改动它。(“Frameworkitis is the disease that a framework wants to do too much for you or it does it in a way that you don’t want but you can’t change it.”)

而且,一个framework要做的比较小,因为,如果framework太大了,那么它可能就会做太多(可能会frameworkitis),而且,不容易学习,学习曲线太长,也不容易维护。

Eria的论述真是非常精彩,而且也解释了Eclipse的一些内部设计。一定要阅读全文


第一部分

Yourit Technorati cosmos Refresh Technorati

如何思考Design Pattern?

Posted @ 8:14 am+8 in Programming, Patterns | Licensed under a Creative Commons License

Artima Developer的总编Bill Venners在对Erich Gamma的一次采访中,仔细讨论了Design Pattern(设计模式)的问题。当我们做设计的时候,我们首先会想到使用设计模式。那么如何使用设计模式?如何用设计模式进行思考?是否当你解决一个问题的时候,必须要使用设计模式?

Bill Venners将把这次访谈的内容分多次,发表在Artima Developer上。Erich Gamma的论述确实精彩,他不仅谈到了当初如何进入Design Pattern这个领域的过程,也谈到了在他开发JUnit的过程中,如何设计JUnit,以及如何在JUnit中使用Design Pattern。

“I think patterns as a whole can help people learn object-oriented thinking: how you can leverage polymorphism, design for composition, delegation, balance responsibilities, and provide pluggable behavior. Patterns go beyond applying objects to some graphical shape example, with a shape class hierarchy and some polymorphic draw method. You really learn about polymorphism when you’ve understood the patterns. So patterns are good for learning OO and design in general.”

“Patterns are distilled from the experiences of experts. They enable you to repeat a successful design done by someone else. By doing so you can stand on the shoulders of the experts and do not have to re-invent the wheel. ”

“Do not start immediately throwing patterns into a design, but use them as you go and understand more of the problem. Because of this I really like to use patterns after the fact, refactoring to patterns. …..
Trying to use all the patterns is a bad thing, because you will end up with synthetic designs—speculative designs that have flexibility that no one needs. These days software is too complex. We can’t afford to speculate what else it should do. We need to really focus on what it needs. ”

“We didn’t just string patterns together when we designed JUnit. We did it test-driven, starting with a test that we wanted to succeed and once it passed we looked into how we could improve the code. ”

第一次访谈的内容。

Who is Erich Gamma?(这个问题好像问的有些傻)
《Design Patterns: Elements of Reusable Object-Oriented Software》,《Contributing to Eclipse: Principles, Patterns, and Plug-Ins》的作者之一;JUnit的作者之一;EclipseJDT的负责人。他目前在IBM的瑞士苏黎世OTI实验室工作。

Yourit , Technorati cosmos Refresh Technorati

Get free blog up and running in minutes with Blogsome | Theme designs available here