floater
Java Jedi
总版主
发贴: 3233
积分: 421
|
于 2004-12-19 02:45
emarket wrote: 如果你的vistable们的结构相对 固定,你可以在不改 visitable 代码的基础上,增加visitor, 从而达到 extendable的目的。
This is the key.
For example, when you design a middleware lib, you should keep this in mind so that users of your lib can extend their own functionalities without changing your code(They don't know your code, they don't own your code, or they don't have the commercial right to do so). That means you could have a simple Visitable interface so users could tap into.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - Martin Fowler, Refactoring - Improving the Design of Existing Code
|