If you ask beginning programmers to write a calendar control, they often think to themselves,
如果你要求一個入門級的程序員寫一個日歷控件, 他們通常會對自己說
“Oh,I,m going to write the world’s best calendar control! It’s going to be polymorphic with respect to the kind of calendar.
啊,我要寫一 個世界上最好的日歷控件,它將會是多形態的日歷
It will have displayers, and mungers, and this, that, and the other.”
它會有顯示器,芒格,還有這個,還有那個,等等
They need to ship a calendar application in two months.
他們需要在兩個月內完成這個控件。
They put all this infrastructure into place in the control, and then spend two days writing a crappy calendar application on top of it.
他們把所有的基礎框架都放到了控件里面,然后花兩天時間在上面寫了一個蹩腳的日歷程序。
They’ll think, “In the next version of the application, I’m going to do so much more.”
他們會想,“下個版本,我會做更 多事情。”
Once they start thinking about how they’re actually going to implement all of these other concretizations of their abstract design,
一旦他們開始思考如何把自己的抽象設計具體化的時候
however, it turns out that their design is completely wrong.
他們就會發現自己的設計完全錯誤。
And now they’ve painted themselves into a comer, and they have to throw the whole thing out.
現在他們把自己逼上了絕路,不得不放棄所有的東西。
I have seen that over and over. I’m a strong believer in being minimalistic.
我經常看見這樣的事。我是一個堅定的“最小化主義者”。
Unless you actually are going to solve the general problem, don’t try and put in place a framework for solving a specific one,
除非你真的是要解決一般性問題,否則就不要嘗試用一個框架來解決具體問題,
because you don’t know what that framework should look like.
因為你根本就不知道那個框架應該是什么樣子。
The Extreme Programmers say, “Do the simplest thing that could possibly work.”
極限編程人員說,“做最簡單的事才能有效。”
Yeah, well, Einstein said that, “Do the simplest thing possible, but no simpler.”
是的。愛因斯坦說過,“要盡可能地最簡單,而不是比較簡單。”
The concern I have about checked exceptions is the handcuffs they put on programmers.
我擔心受控異常會成為程序員的手銬。
You see programmers picking up new APIs that have all these throws clauses,
當你看見程序員拿到如此有著復雜拋出語句的新應用程序界面的時候,
and then you see how convoluted their code gets, and you realize the checked exceptions aren’t helping them any.
你會發現他們的代碼是如此的回繞,你會意識到受控異常對他們沒什么幫助。
It is sort of these dictatorial API designers telling you how to do your exception handling.
這好像是專制的應用程序界面設計者告訴你必須怎樣進行異常處理。
They should not be doing that.
他們不應該那樣做。