軟件工程師的10個認知模型

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"如果你看過查理芒格的,或者聽過羅振宇的,應該對非常熟悉","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"多元思維模型","attrs":{}},{"type":"text","text":"這個概念。思維模型又稱爲心智模型,英文爲mental model,是認知心理學的一個概念,用於解釋個體爲現實世界中之某事所運作的內在認知歷程(wikipedia)。如今思維模型的範圍被擴展了很多,基本上囊括了人類解決問題時所使用的各種思考框架、設計原則,以及心理學的各種認知偏差、非理性行爲等。多元思維模型就是強調在思考問題的過程中,要綜合考慮各種場景的可能性,充分借用各學科的有效工具,只有在多維度思考的過程中,纔有可能逼近真相。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"軟件工程師在構建複雜系統的時候,也會有意無意的應用大量認知模型,正是這些有效的認知模型,幫助我們構建了當今無比複雜的信息系統,把全球所有60億人口都裹挾進了數字智能時代。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這篇文章介紹了在軟件系統設計與開發過程中最常用的10個認知模型。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"1. 抽象","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"抽象也許是設計複雜系統的最重要的工具,抽象能力的高低是軟件工程師優秀與平庸的最重要的區別之一,抽象能力的強弱直接決定了我們解決問題的規模大小和複雜度。當我們在設計一個通信系統的時候,簡單來說會做如下抽象:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"接入網","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"|- IP接入","attrs":{}}]},{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"|- 安全網關","attrs":{}}]},{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"|- 應用層接入","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"核心網","attrs":{}}]}]}],"attrs":{}},{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"|- 註冊服務","attrs":{}}]},{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"|- 業務管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"|- 應用服務器","attrs":{}}]},{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"|- 用戶數據庫","attrs":{}}]},{"type":"paragraph","attrs":{"indent":2,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"|- 路由管理","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這些都是在一個層面上的抽象,使得開發者在開發系統的時候可以專注於當前抽象的模塊,業務流程更爲清晰,降低開發時的心智負擔。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"抽象在具體實現過程中,有兩種最重要的模型,一是","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"分層","attrs":{}},{"type":"text","text":",二是","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"分治","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"2. 分層","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"分層就是把一個複雜系統劃分成若干個層次,每一層專注於解決某一領域的問題,並向上層提供服務,上層解決的問題依賴於下層提供的抽象。有些層解決的問題可能會需要與其他所有層進行交互,這種層體現在層次圖上就是一個縱向的層(比方說監控、配置管理等)。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/e0/e0d8a4a63936067983875ca8a59295dc.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","marks":[{"type":"size","attrs":{"size":9}}],"text":"分層架構","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通信系統中著名的OSI協議模型,以及我們每個人每天上網的時候都會用到的TCP/IP協議棧,就是最典型的分層設計模型。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/65/65b2795dc6872a4d5a583849786e7d94.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","marks":[{"type":"size","attrs":{"size":9}}],"text":"TCP/IP模型和OSI模型","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們整個人類社會其實都是分層設計,比方說在企業裏,最下面是底層勞動者,中間有各級經理、總監等管理者,上面是一堆CXO,再往上還有董事會。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"3. 分治","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"分治就是分而治之,是人類自古以來應對複雜問題的最直觀的解決方案。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/16/16e1221a549d034c6c39c85a2eff803e.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當我們面對一個複雜的大問題,我們可以把這個問題分解成若干個較小的問題,如果這些小問題還是太複雜,我們就進一步分解,知道每一個小問題都可以通過可行的步驟解決爲止。在小問題解決以後,我們再一步步把每一個小問題的解決方案以及結果組合起來,最終解決那個複雜的大問題。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Google提出的MapReduce算法就是一個典型的分治的例子。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/95/9561ead64cfd3eec49b91958f417223f.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"簡單來說,MapReduce包括兩個步驟,一是Map,二是Reduce。通過Map,把一個輸入數據映射爲多個數據,然後對這多個數據同時進行運算處理,然後通過Reduce把運算的結果綜合起來得到輸入數據的最終結果。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"分治思想其實體現在我們生活的方方面面,從政治上的封建諸侯、郡縣制到現代公司裏的分公司、產品線,可以說如果沒有分治思想,人類就不可能進行大規模協作,因此也不可能發展出當前的文明。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"4. 演化","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"任何事物都處在動態發展的過程中,軟件系統也不例外。隨着時間的推移,一個軟件系統的業務需求、運行環境可能會不斷髮生變化,這就要求軟件系統本身能夠適應這些變化,不斷進行演化。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"比方說,某個創業公司一開始設計一個通信系統的時候,可能只需要支持1萬個用戶,那用單體架構(所有功能跑在一個進程內,這個進程部署在一臺機器上)就完全可以滿足需求。慢慢的,用戶越來越多,團隊規模越來越大,爲了方便業務開發及管理,就需要劃分功能,抽象出若干個功能模塊(註冊、鑑權、呼叫等),每個功能跑在單獨的機器上,由單獨的部門維護,組合起來完成整個業務需求。隨着用戶的增長,每個功能模塊的性能都到了極限,這時候就需要考慮用把每個功能抽象成單獨的服務,部署在服務器集羣上,使每個功能可以獨立優化、擴展,這時候可能還會有單獨的部門維護服務器集羣,提供各個業務都需要的底層功能。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/fd/fdc5ab7ac08f242a2c7236ac76086e80.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"架構師的一項核心能力就是根據業務、環境的迭代,不斷推動架構的演化,保證系統架構走在業務演進的前面,而不會成爲業務發展的絆腳石。在架構設計的時候,要充分考慮到系統演化的需求,在設計上要考慮靈活性,以應對將來的演化需求。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一般來說,一個軟件產品演化的起點是","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"MVP","attrs":{}},{"type":"text","text":",通過","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"重構","attrs":{}},{"type":"text","text":"的方式推進系統的演化,同時在開發過程中要儘量遵循","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"KISS","attrs":{}},{"type":"text","text":"原則。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"5. MVP","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"MVP是Minimum Viable Product的縮寫,意思是最小化可行性產品,是","attrs":{}},{"type":"text","marks":[{"type":"italic","attrs":{}},{"type":"strong","attrs":{}}],"text":"精益創業","attrs":{}},{"type":"text","text":"提出的一個概念,意思是用最小的代價發佈可用的產品,從而最大程度的獲得用戶的反饋並驗證產品的商業可行性。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/55/55528f7e3fb0e58b97cdd3cd44e4feb9.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在很多情況下,開發一款完整產品的代價是非常昂貴的,在市場接受度不確定的情況下,創業公司可以通過MVP不斷驗證產品設計和市場反應,然後慢慢通過演化的方式迭代產品。即使是微信這樣成功的產品,在一開始也是從很單一的功能開始迭代的:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/f2/f2b7d76eedb061a6a6f5b5f3324e4645.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"MVP的思想在社會學上同樣有所體現,比方說歷史上空想社會主義者建立的實驗性社區,中國改革開放初期的特區等。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"6. 重構","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"重構是進行系統演化的重要手段,小到一個變量名,大到整個系統,都需要不斷進行重構。重構就是在不改變外部行爲的前提下,優化內部實現。這種優化可以是提高代碼的可讀性,增強代碼的靈活性,或者改變代碼內部結構與設計。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/d0/d0be5d4faf43664e16a267b8a6474d78.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一般來說,當我們決定要進行重構的時候,出發點總是好的,總是希望能夠把原來意大利麪條似的的代碼整理成清晰美觀又靈活的代碼。但是,現實並不總是像想象的那樣美好。比方說蘇州的倫敦橋:","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/eb/eb7cab0ad9763081b6c872058e70e27a.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"7. KISS","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"KISS是Keep It Simple, Stupid的首字母縮寫。這是一種經驗原則,要求設計系統的時候儘量保持簡單。換句話說,“簡單就是美”。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當把KISS原則用在用戶體驗的設計上時,就是要把一個產品做的連白癡都會用。最典型的就是蘋果公司的極簡主義設計哲學。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/89/896469e4a4d509fab269f08508d1401d.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"當把KISS原則應用在代碼設計上時,核心就是要保持模塊的功能單一,所謂的高內聚、低耦合。最典型的例子就是UNIX的設計哲學:","attrs":{}}]},{"type":"bulletedlist","content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"小即是美。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"讓程序只做好一件事。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"儘可能早地創建原型。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可移植性比效率更重要。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"數據應該保存爲文本文件","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"儘可能地榨取軟件的全部價值。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用shell來提高效率和可移植性。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"避免使用可定製性低下的用戶界面。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"所有程序都是數據的過濾器。","attrs":{}}]}]}],"attrs":{}},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"8. 設計模式","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"設計模式代表了開發人員一致認同的最佳實踐,每一個設計模式都描述了一個典型問題的通用解決方案,可以使開發人員能夠用簡潔一致的術語進行溝通,減少溝通過程中的不確定性,並且可以提供一個較高的抽象層次。設計模式就像一套久經考驗的模板,當你碰到某些問題的時候,如果能簡單的套用模板,就可以快速高效的解決問題。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/a9/a9e6b60693f2c92a3c377b35adb79ad4.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"比方說,如果你的系統裏有若干個子系統,其中一個子系統的狀態變化需要通知到其他子系統,這時候就可以應用","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"觀察者模式","attrs":{}},{"type":"text","text":"。或者,你的系統在不同的情況下需要和不同的外部系統(比方說不同的數據庫)進行交互,這時候就可以應用","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"接口模式","attrs":{}},{"type":"text","text":"把不同外部系統的差異封裝起來。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"設計模式在非技術領域也有很多應用,比方說國內科技公司流行的VIE架構,就是一種解決美元資本和國內政策限制的一個有效的商業設計模式。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/d9/d93b8b97f715b84eae6547f5ced849b3.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","marks":[{"type":"size","attrs":{"size":9}}],"text":"VIE架構示例","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"9. 協議","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"計算機系統在進行通信的時候,通常會指定一套統一的協議,通信各方都遵循同樣的語法、語義、時序進行通信。通信協議就像人類的語言,大家都遵從同樣的一套系統,纔可以互相理解溝通。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在互聯網領域,使用最廣泛的就是TCP/IP協議族。協議族是由很多個協議組成的一個協議家族。其中最重要的是IP和TCP兩個協議,這也是我們平時上網時用的協議。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/d8/d86a968484149de207835b943121790d.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":"center","origin":null},"content":[{"type":"text","marks":[{"type":"size","attrs":{"size":9}}],"text":"TCP通信流程","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我們在開發一個新系統的時候,只要遵從大家都認可的協議,就可以保證可以和遵從同樣協議的系統通信。比方說,我們開發新的網站,只要遵從HTTP協議,頁面用HTML/JavaScript開發,就可以保證瀏覽器可以訪問到我們的網站,而不用管瀏覽器是怎麼開發的。只要對外提供服務的接口協議保持不變,不管內部架構如何演化,都可以保證對外提供一致的服務。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"類似的,摩斯碼是電報通訊的標準協議,只要收發雙方都用摩斯碼,就可以把消息發送到全世界。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"10. 不要重複發明輪子","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"“不要重複發明輪子”的意思是儘可能複用已有的代碼、模塊、框架、系統、服務等基礎設施,其核心邏輯是","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"複用","attrs":{}},{"type":"text","text":"。複用的好處有很多:保持代碼簡單,更好的可維護性,更短的開發時間,業界的最佳實踐等。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"比方說,如果你想自己搭建一個博客,或者簡單的商務網站,直接用WordPress就可以了,甚至不用寫一行代碼。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"而有賴於開源領域的各位大牛的貢獻,我們現在甚至可以通過組裝各個開源模塊構建一個複雜的分佈式系統。","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/9b/9b8dc3313b0c43b7c7d0318785be480e.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"既然有橋可以過,爲什麼非要摸石頭呢?既然有好的模塊可以用,那就不要自己造輪子了唄。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":1},"content":[{"type":"text","text":"寫在最後","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這10個認知模型是軟件工程師在平時工作中最常用的,同時也被應用在社會、商業等各個方面。","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"抽象","attrs":{}},{"type":"text","text":"、","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"分層","attrs":{}},{"type":"text","text":"、","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"分治","attrs":{}},{"type":"text","text":"幫助我們站在更高的角度分析架構設計;","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"演化","attrs":{}},{"type":"text","text":"、","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"MVP","attrs":{}},{"type":"text","text":"、","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"重構","attrs":{}},{"type":"text","text":"、","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"KISS原則","attrs":{}},{"type":"text","text":"讓我們以儘量靈活的方式設計系統;","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"設計模式","attrs":{}},{"type":"text","text":"爲我們提供了一套精煉有效的問題解決模板;","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"協議","attrs":{}},{"type":"text","text":"使系統的接口和實現可以分離,並且使不同的系統可以直接通信,而不用考慮各自的實現;","attrs":{}},{"type":"text","marks":[{"type":"strong","attrs":{}}],"text":"不要重複發明輪子","attrs":{}},{"type":"text","text":",站在巨人的肩膀上。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"希望這10個認知模型能夠幫助你更好的解決問題。","attrs":{}}]}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章