聽老外吐槽框架設計,Why I Hate Frameworks?

碼農參上發表於2021-12-06

原創:微信公眾號 碼農參上,歡迎分享,轉載請保留出處。

Hello,小夥伴們,今天不聊技術,分享點有意思的東西。前段時間,表弟給我發過來一篇老外寫的文章,以略帶諷刺的對話方式調侃了自己對框架的看法,我在讀了一下以後也感覺比較有趣,這裡分享給大家。

作者Benji Smith,可惜目前在這位老哥的個人網站上已經找不到這篇文章的原文了,只剩下了一段自我介紹。這裡最後在國內的技術論壇裡找到了英文原文和其他的大佬的翻譯,這裡我參考了一些版本的譯文,配合自己的理解重新進行了一波翻譯,並新增了一些插圖,方便大家更容易地理解原文。

好了,下面就來看一下正文吧。

正文

目前,我正處於構建一個Java web應用的計劃階段(是的,必須要使用Java,而其中各式各樣的原因我現在並不想去討論)。在這個過程中,我評估了一系列基於角色的CMS服務應用容器框架,並且它們基本使用了J2EE門戶設計、遵循JSR規範的MVC架構。

I'm currently in the planning stages of building a hosted Java web application (yes, it has to be Java, for a variety of reasons that I don't feel like going into right now). In the process, I'm evaluating a bunch of J2EE portlet-enabled JSR-compliant MVC role-based CMS web service application container frameworks.

但是在花了幾十個小時閱讀功能列表和文件後,我真想摳出我的眼珠子。

And after spending dozens of hours reading through feature lists and documentation, I'm ready to gouge out my eyes.

讓我們假設我決定做一個放香料的架子。

Let's pretend I've decided to build a spice rack.

在以前,我做過一些零碎的木匠活,因此我很清楚我到底需要什麼:一些木頭以及基礎的工具,例如捲尺、鋸子、水平儀和錘子。

I've done small woodworking projects before, and I think I have a pretty good idea of what I need: some wood and a few basic tools: a tape measure, a saw, a level, and a hammer.

如果我要建造一整棟房屋,而不僅是一個香料架的話,那麼我需要的還是捲尺、鋸子、水平儀、錘子以及其他的一些東西。

If I were going to build a whole house, rather than just a spice rack, I'd still need a tape measure, a saw, a level, and a hammer (among other things).

所以我去了一家五金店,然後詢問店員我在哪裡能買到一把錘子。

So I go to the hardware store to buy the tools, and I ask the sales clerk where I can find a hammer.

“一把錘子?”他問道,“現在已經沒有人再買錘子了,它們已經過時了。”

"A hammer?" he asks. "Nobody really buys hammers anymore. They're kind of old fashioned."

我被這一發展趨勢震驚了,並問他原因。

Surprised at this development, I ask him why.

“嗯,錘子的問題就在於它有太多的種類了,就像大錘、羊角錘、球頭錘等等。如果你買了一把後突然意識到你還需要另一種類的錘子怎麼辦呢,你還需要為你下一個任務再單獨買一把。事實證明,大多數人需要一把能夠解決生活中可能遇到的所有敲打任務的錘子。”

"Well, the problem with hammers is that there are so many different kinds. Sledge hammers, claw hammers, ball-peen hammers. What if you bought one kind of hammer and then realized that you needed a different kind of hammer later? You'd have to buy a separate hammer for your next task. As it turns out, most people really want a single hammer that can handle all of the different kinds of hammering tasks you might encounter in your life."

“呃,嗯,我認為這聽起來確實不錯。那麼你能告訴我哪裡能找到這麼一把萬能的錘子嗎?”

"Hmmmmmm. Well, I suppose that sounds all right. Can you show me where to find a Universal Hammer."

“不,我們已經不賣它了,它已經被淘汰了。”

"No, we don't sell those anymore. They're pretty obsolete."

“是真的嗎?但是你剛才還在說萬能錘子是未來的潮流不是嗎?”

"Really? I thought you just said that the Universal Hammer was the wave of the future."

“事實證明,如果你僅僅製造出一種能夠完成所有任務的錘子,它們反而不能很有效的處理其中的任何一件任務,就像用一把大錘去釘釘子就會很費力。並且,如果你想殺了你前任女友的話,真沒有什麼能夠代替一把球頭錘。”

"As it turns out, if you make only one kind of hammer, capable of performing all the same tasks as all those different kinds of hammers, then it isn't very good at any of them. Driving a nail with a sledgehammer isn't very effective. And, if you want to kill your ex-girlfriend, there's really no substitute for a ball-peen hammer."

“這倒是真的。那麼,如果沒有人買這種萬能錘子的話,而你們也不再賣那些老款式的錘子的話,你們到底賣什麼錘子呢?”

"That's true. So, if nobody buys Universal Hammers anymore, and if you're no longer selling all those old-fashioned kinds of hammers, what kinds of hammers do you sell?"

“實際上,我們根本不賣錘子”

"Actually, we don't sell hammers at all."

“那麼……”

"So..."

“根據我們的研究,人們真正需要的根本就不是萬能錘子,最好還是能有一把合適型別的錘子來適用於不同的工作。因此,我們開始出售錘子工廠,它能夠生產你可能感興趣的各式各樣的錘子。而你需要做的就是,為錘子工廠招聘工人、啟動機器、購買原材料、支付水電費等等……很快你就能得到你所需要的那種特定的錘子。”

"According to our research, what people really needed wasn't a Universal Hammer after all. It's always better to have the right kind of hammer for the job. So, we started selling hammer factories, capable of producing whatever kind of hammers you might be interested in using. All you need to do is staff the hammer factory with workers, activate the machinery, buy the raw materials, pay the utility bills, and PRESTO...you'll have exactly the kind of hammer you need in no time flat."

“但是我真的不想買一個錘子工廠…”

"But I don't really want to buy a hammer factory..."

“那就對了,因為我們早就不賣錘子工廠了。”

"That's good. Because we don't sell them anymore."

“但我聽見你剛才還在說……”

"But I thought you just said..."

“我們發現,其實大多數人實際上並不需要一個完整的錘子工廠,例如有一些人可能永遠用不到球頭錘(或者是因為他們根本就沒有前女友,或者他們可以用冰鎬來代替錘子來殺死她們)。因此對人們來說,買一個能生產各種錘子的錘子工廠是沒有意義的。”

"We discovered that most people don't actually need an entire hammer factory. Some people, for example, will never need a ball-peen hammer. (Maybe they've never had ex-girlfriends. Or maybe they killed them with icepicks instead.) So there's no point in someone buying a hammer factory that can produce every kind of hammer under the sun."

“嗯,這麼聽上去確實挺合理。”

"Yeah, that makes a lot of sense."

“因此作為代替,我們開始出售錘子工廠的設計圖,以便我們的客戶能夠搭建自己的錘子工廠,通過定製設計,只生產他們實際需要的那些種類的錘子。”

"So, instead, we started selling schematic diagrams for hammer factories, enabling our clients to build their own hammer factories, custom engineered to manufacture only the kinds of hammers that they would actually need."

“讓我猜一下,你們肯定也不再出售這些設計圖了”

"Let me guess. You don't sell those anymore."

“沒錯,當然不了。事實證明,人們不會僅僅為了製造幾把錘子就去建造一整個工廠。把工廠的建造留給工廠建造專家,這才是我常常說到的。”

"Nope. Sure don't. As it turns out, people don't want to build an entire factory just to manufacture a couple of hammers. Leave the factory-building up to the factory-building experts, that's what I always say!!"

“我很同意你的觀點。”

"And I would agree with you there."

“是的,所以我們停止出售那些設計圖,轉而去出售建造錘子工廠的工廠。每個建造錘子工廠的工廠都是由這一領域的頂級業務專家為你建造的,因此你不需要擔心建造工廠的任何細節。你仍然可以享受自定義錘子工廠的所有優點,根據你自己特殊錘子的設計,生產你自己的定製錘子。”

"Yup. So we stopped selling those schematics and started selling hammer-factory-building factories. Each hammer factory factory is built for you by the top experts in the hammer factory factory business, so you don't need to worry about all the details that go into building a factory. Yet you still get all the benefits of having your own customized hammer factory, churning out your own customized hammers, according to your own specific hammer designs."

“嗯,那實際上並不……”

"Well, that doesn't really..."

“我知道你要說什麼!!…我們早就不出售這些東西了。出於某些原因,並沒有多少人去購買建造錘子工廠的工廠,因此我們想出了新的解決方案來處理這個問題。”

"I know what you're going to say!! ...and we don't sell those anymore either. For some reason, not many people were buying the hammer factory factories, so we came up with a new solution to address the problem."

“呃,嗯。”

"Uh huh."

“當我們回過頭來,再審視這個統一工具的底層時,發現人們苦惱於管理這個建造錘子工廠的工廠、以及它生產出來的錘子工廠。如果你同時需要運營捲尺工廠的工廠、鋸子工廠的工廠、水平儀工廠的工廠的話,那麼開銷會變的非常龐大,更不用說運營一家木材製造集團控股公司了。當我們真正考慮到這種情況的時候,我們認為這對於一個只想做一個香料架子的人來說,實在是過於複雜了。”

"When we stepped back and looked at the global tool infrastructure, we determined that people were frustrated with having to manage and operate a hammer factory factory, as well as the hammer factory that it produced. That kind of overhead can get pretty cumbersome when you deal with the likely scenario of also operating a tape measure factory factory, a saw factory factory, and a level factory factory, not to mention a lumber manufacturing conglomerate holding company. When we really looked at the situation, we determined that that's just too complex for someone who really just wants to build a spice rack."

“是的,這可不是鬧著玩的。”

"Yeah, no kidding."

“所以這個星期,我們正在推廣一種通用型的工廠,用來建造生產工具工廠的工廠,這樣一來,所有用來建造不同種類工具的工廠的工廠,就可以由一個單一和統一的工廠來建造了。這種通用工廠只生產你實際需要的工具工廠的建造工廠,而這些建造工廠將生成一個僅生產你自定義的工具的工廠。在這個過程中最後產生的工具,就是你特定工程需要的理想工具。最後只需要按下一個按鈕,你就能夠得到你需要的錘子和捲尺(儘管有可能你還需要部署一些配置檔案,來使它按照你的期望工作)。”

"So this week, we're introducing a general-purpose tool-building factory factory factory, so that all of your different tool factory factories can be produced by a single, unified factory. The factory factory factory will produce only the tool factory factories that you actually need, and each of those factory factories will produce a single factory based on your custom tool specifications. The final set of tools that emerge from this process will be the ideal tools for your particular project. You'll have exactly the hammer you need, and exactly the right tape measure for your task, all at the press of a button (though you may also have to deploy a few configuration files to make it all work according to your expectations)."

“所以說你們根本就沒有錘子,對嗎?”

"So you don't have any hammers? None at all?"

“是的,如果你真的需要一個高質量的、符合工業設計的香料架,你絕對需要這些更先進的東西,而不是一把能隨便從破舊五金店買到的普通錘子。”

"No. If you really want a high-quality, industrially engineered spice rack, you desperately need something more advanced than a simple hammer from a rinky-dink hardware store."

“現在每個人都是這樣做的嗎?當需要一把錘子的時候,他們都在使用一個通用的能夠生產工具工廠的建造工廠的工廠嗎?”

"And this is the way everyone is doing it now? Everyone is using a general-purpose tool-building factory factory factory now, whenever they need a hammer?"

“是的。”

"Yes."

“那麼…好吧。我想這就是我必須要做的了。如果這就是處理事情的解決方案的話,我想我最好學學怎麼使用它吧。”

"Well…All right. I guess that's what I'll have to do. If this is the way things are done now, I guess I'd better learn how to do it."

“祝你好運!”

"Good for you!!"

“這玩意兒一定是有文件的,對吧?”

"This thing comes with documentation, right?"

現在,我已經自豪的擁有了自己的通用的工具工廠的建造工廠的建造工廠,我很欣慰地知道它與GPTBFFF 0.97 RC2草案相相容,這一草案正是用來規範“通用的工具工廠的建造工廠的建造工廠”標準。

Now that I'm the proud owner of my own general-purpose tool-building factory factory factory, I'm satisfied to know that it complies with the GPTBFFF 0.97 RC2 draft specification for tool-building factory factory factories.

幸運的是,在面向工具的元工廠聯盟中,70%的工人通過了這一版本規範的認證。

Luckily, 70% of the workers in the Tool-Oriented Metafactory Union are certified against this version of the spec.

然而標準之爭已初露端倪,一項名為UXCTBFFF(通用跨大陸工具製造FFF)的元工廠技術非常具有競爭力,它承諾將要統一通用工廠的建造工廠的建造工廠標準,來滿足那些同時使用通用工廠方法和標準原始工具作為方案的的場景。

On the horizon is a competing standard, though: a very compelling metafactory technolgy called the UXCTBFFF (Universal Trans-Continental Tool Building FFF), which promises to unify the factory factory factory industry to comply with guidelines of countries that use both metric and standard tools.

我的理解是,只要在使用者介面上建立一個抽象層,肯定會有一個補丁包能使我的GPTBFFF 0.97 RC2與UXCTBFFF標準達到95%左右的相容。

My understanding is that there will be a service pack to my GPTBFFF 0.97 RC2 to bring it into nearly 95% compliance with the UXCTBFFF standard, just by creating an abstraction layer through its user interface.

太棒了!!

Sweet!!

毫無疑問,這種新的發展一定能提高我的香料架子的質量(總有一天,當我搭建好我的通用工具工廠的建造工廠的建造工廠並使它開始運轉、培訓好我的勞動力、從柬埔寨進口好原材料後,我就要開始著手做我的香料架子了)。

Surely this new development will improve the quality of my spicerack (which I'll get around to building one of these days, as soon as I've got my factory factory factory all up and running, my labor force trained, my raw materials imported from Cambodia, etc).

-- End --

Benji Smith個人網站:

http://www.benjismith.net/

原文及譯文參考:

https://www.cnblogs.com/kkjmyazi/archive/2006/11/29/576573.html

PS:

因為文中有很多我也不確定翻譯是否正確的地方,所以貼出了英文原文。例如對於文中“which promises to unify the factory factory factory industry to comply with guidelines of countries that use both metric and standard tools.”這一句,如果從字面上進行翻譯的話後半句大致意思是“使它符合一些同時使用公制和標準工具的國家的標準”,而我決定將它引申為“同時使用通用工廠方法和標準原始工具”。

諸如此類的地方,如果您有更好的建議,可以在公眾號後臺直接傳送建議給我,萬分感謝!

作者簡介,碼農參上,一個熱愛分享的公眾號,有趣、深入、直接,與你聊聊技術。個人微信DrHydra9,歡迎新增好友,進一步交流。

相關文章