學了那麼多技術,爲何依然成不了架構師

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在我們的周圍存在着很多的全棧工程師,極客達人,他們熱愛技術,善於使用各種工具,甚至可以熟練使用多種開發語言,解決各種技術上的問題,但是卻無法成爲掌控全局的架構師,無法做出最優的架構決策,這是爲什麼呢?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"架構中的哲學"}]},{"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":"在《道德經》中提到四個字,叫“道、法、術、器”。“道”是天道,“法”是人定的,就是說你該怎麼跟着“天道”去做。“法”也有善惡之分。順應天道的“法”就是善法,相反,違背天道的“法”就是惡法。“術”是指技術層面上的操作方法。“器”是指有型的物質或是有形的工具。"}]},{"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":"無獨有偶,在學習陽明心學的時候,其核心教義也和道家思想一脈相承。"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/68/68bc3cb212f54dc5f3425299cf8b930f.jpeg","alt":null,"title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"無善無惡是自然之道,有善有惡是人性之法,知善知惡需判別之術,爲善去惡用合法之器。他們不是含義上的等價,卻是哲學思想層次的完美統一。從道出發,以法爲界,以道御術,善於用器。這是一個循序漸進的過程,是解決問題的步驟和方法論。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對於大部分程序員來說,不論是我們參與的工作,還是接受的培訓,基本都屬於“器”、“術”的範疇。而架構師具備能力:理解業務,全局把控"},{"type":"text","marks":[{"type":"strong"}],"text":"(道)"},{"type":"text","text":",選擇合適技術"},{"type":"text","marks":[{"type":"strong"}],"text":"(法)"},{"type":"text","text":",解決關鍵問題"},{"type":"text","marks":[{"type":"strong"}],"text":"(術)"},{"type":"text","text":",指導研發落地實施"},{"type":"text","marks":[{"type":"strong"}],"text":"(器)"},{"type":"text","text":"。可見成爲一名合格的架構師,不僅僅只是具備技術能力就可以完全勝任的,還需要領悟架構之道,架構之法併合理的應用。"}]},{"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":"何爲架構的道、法、術、器呢?"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"道"},{"type":"text","text":":架構設計的方向,大道至簡。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"法"},{"type":"text","text":":架構設計的原則,有據可依。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"術"},{"type":"text","text":":架構設計的技巧,有題可解。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"器"},{"type":"text","text":":架構設計的工具,有器可用。"}]},{"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":"王陽明的思想最核心的是“知行合一”,對於程序員來說,我們從從事的工作中可以逐步的向上昇華,從而建立起知的過程。我們也應該去學習架構的思想和方法,來不斷的應用到自己的工作中,讓我們做的更好。"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/29/29b19cb01ccb529376ac4baf6f033e98.jpeg","alt":null,"title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"回顧架構之“道”"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"軟件架構之道最核心的問題是解決複雜性的問題,並且在解決問題的過程中找到最佳的平衡點,既要簡單又能滿足發展。"},{"type":"text","text":"在前面的文章裏,我分享了四種解決複雜性問題的四種最最重要的武器,首先先回顧一下:"}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"抽象思維"},{"type":"text","text":"--"},{"type":"link","attrs":{"href":"https://m.toutiaocdn.com/i6834895666334925316/?app=newsarticle&timestamp=1594966130&usenew_style=1&req_id=202007171408490100140400873B1BA8F4&group_id=6834895666334925316","title":""},"content":[{"type":"text","text":"《無抽象不架構》"}]},{"type":"text","text":":抽象思維是架構思維最最核心的思維能力,不具備抽象思維就無法化繁爲簡,複用和擴展也就無從談起。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"分層思維"},{"type":"text","text":"--"},{"type":"link","attrs":{"href":"https://m.toutiaocdn.com/i6836762796349194763/?app=newsarticle&timestamp=1594966233&usenew_style=1&req_id=20200717141033010014047036131B2E8C&group_id=6836762796349194763","title":""},"content":[{"type":"text","text":"《想解耦必分層》"}]},{"type":"text","text":":架構的核心是解耦和複用,而分層是基於調用鏈來劃分職責的一種方式,只有職責單一清晰,才能真正解耦。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"分治思維"},{"type":"text","text":"--"},{"type":"link","attrs":{"href":"https://m.toutiaocdn.com/i6838954850621850125/?app=newsarticle&timestamp=1594966564&usenew_style=1&req_id=20200717141604010014061016011BD006&group_id=6838954850621850125","title":""},"content":[{"type":"text","text":"《凡架構必拆分,分則有度》"}]},{"type":"text","text":":複雜的問題需要分解成一個個的小問題才能更容易的解決,架構其中一個目的就是管理系統的複雜性,而分治思維是管理複雜性必不可少的手段,微服務架構是分治思維的一種體現。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"演化思維"},{"type":"text","text":"--"},{"type":"link","attrs":{"href":"https://m.toutiaocdn.com/i6844554210034319630/?app=newsarticle&timestamp=1594966616&usenew_style=1&req_id=202007171416560100140400822B190E2E&group_id=6844554210034319630","title":""},"content":[{"type":"text","text":"《架構設計過度有時比設計不足更可怕》"}]},{"type":"text","text":":架構是設計出來的,更是演化出來的,設計不足會使後續升級成本提高,而過度設計則會讓現在爲期望提前買單,都是得不償失的。適可而止的架構加時刻保持演進的變化是最合理的做法。"}]}]}]},{"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":"之所以花了那麼多篇幅去討論架構之道,因爲“道”是方向,沒有方向的努力也許是徒勞的。一個好的架構師或者成爲一個好的架構師的潛力的程序員都應該去學習並領悟架構之道。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"聊聊架構之“法”"}]},{"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":"“道”是抽象的,是形而上的,對它的認知每個人因爲能力和悟性均有差異,這也是決定我們能否在這條道路上走多遠的先決條件。軟件架構之道在於找到設計的平衡點,使得架構足夠簡單,又能夠滿足需要,同時還要兼顧發展,這句話說起來簡單,但是做起來特別的難。每個人對於平衡點的把握都是有差異的,因爲修道有深淺,而且很容易被外界的因素干擾,最終造成的差異也是巨大的。有沒有可以依據的原則讓抽象的“道”更加具體,讓個體的差異不再那麼明顯呢?這就是道家所說的“法”,即根據自然發展規律人爲制定的原則和法則。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"通用原則"}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"KISS原則"},{"type":"text","text":":Keep it simple and stupid.簡單未必愚蠢,很多時候大智若愚。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"最小代價(努力)原則"},{"type":"text","text":":程序猿的惰性與生俱來,我們總是選擇最容易行走的路徑。這也是爲什麼我們應該儘可能在一開始的時候,作出正確的選擇,因爲一旦這個架構設計出現,後面的人很有可能不願意爲了更好的架構而改進,而是遵循已有的設計。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"最小意外原則"},{"type":"text","text":":好的設計應該避免意外,遵守通用的規範和習慣。這些意外其實是軟件架構和設計中的複雜因素。最小意外也就意味着儘可能的簡單。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"DRY原則"},{"type":"text","text":":“Dont repeat yourself” 告訴我們應該儘可能的消滅重複和冗餘。重複使的軟件的閱讀,修改,測試變得複雜,消滅重複,是使軟件變得簡單的手段之一。"}]}]}]},{"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":"在架構設計的通用原則裏,核心的思想是爲了讓系統或者其動態發展變得更加簡單而不是讓它更加複雜。但簡單和複雜卻又是形影相隨的孿生兄弟,你如果要擴展簡單,那麼就可能封裝複雜;你如果想使用簡單,那麼就可能實現複雜;你如果過想開發簡單,那麼就可能運維複雜。這看似非常矛盾,其實架構就是一種選擇和平衡的藝術,你選擇面對的主體是誰,你就讓它更加簡單。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"設計模式的七大原則"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/65/65369d38bfb86b6e35a9f380d52bbbb0.png","alt":"GoF23種設計模式的關係","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"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":"23種設計模式對程序員來說想必都不陌生,它指導我們寫出更優雅、更健壯、更具有擴展性的面向對象的程序。我認爲設計模式的內容,更偏向架構之“術”,它教給我們具體的設計方法。但軟件設計模式和麪向對象的設計都基於一些常見的原則:"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"numberedlist","attrs":{"start":"1","normalizeStart":1},"content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"單一職責原則"},{"type":"text","text":":告訴我們實現類要職責單一。其實不光是寫程序,我們在做分層設計,以及微服務組件拆分時,單一職責都是指導性的原則。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"里氏替換原則"},{"type":"text","text":":告訴我們不要破壞繼承體系。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":3,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"依賴倒置原則"},{"type":"text","text":":告訴我們要面向接口編程。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":4,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"接口隔離原則"},{"type":"text","text":":告訴我們在設計接口的時候要精簡單一。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":5,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"迪米特法則"},{"type":"text","text":":告訴我們要降低耦合。在領域驅動設計方法中,迪米特的最小知道原則也是指導我們領域劃分的重要法則。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":6,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"合成複用原則"},{"type":"text","text":":告訴我們少用繼承。"}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":7,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"開閉原則"},{"type":"text","text":":告訴我們要對擴展開放,對修改關閉。開閉原則是面向對象中最基礎的原則,抽象構建框架,用實現擴展細節。可以提高軟件系統的可維護性和可複用性。這是設計模式七大原則最重要的設計原則,應用在各個地方。"}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"專有領域的設計原則"}]},{"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":"不論是架構的通用原則還是設計模式的原則基本上都是普遍通用的原則,幾乎對所有的開發者,架構師都有用。其實設計原則也是有層級或者有領域的,在不同的領域有自己特有的設計原則。比如在分佈式系統開發領域,就需要遵守著名的"},{"type":"text","marks":[{"type":"strong"}],"text":"CAP原則"},{"type":"text","text":"(指的是在一個分佈式系統中,一致性(Consistency)、可用性(Availability)、分區容錯性(Partition tolerance)這三個要素最多隻能同時實現兩點,不可能三者兼顧。),在數據庫設計領域,你不得不瞭解"},{"type":"text","marks":[{"type":"strong"}],"text":"ACID"},{"type":"text","text":"(ACID 爲 Atomicity, Consistency, Isolation, and Durability,強制一致性,要麼全做要麼不做,所有用戶看到的數據一致。強調數據的可靠性, 一致性和可用性。)和"},{"type":"text","marks":[{"type":"strong"}],"text":"BASE"},{"type":"text","text":"(BASE爲Basically Available, Soft-state, Eventually consistent,表示爲支持可用性,犧牲一部分一致性,可以顯著的提升系統的伸縮性,數據爲最終一致。和ACID爲相反的方向。其中事務支持不會很高.)這兩種設計原則的區別和應用場景。"}]},{"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":"甚至在一個團隊中也要遵從團隊中特有的一些設計原則,比如每個團隊都有自己的開發規範,命名規範,過去在做互聯網領域的開發時,我禁止團隊成員使用存儲過程,這些設計原則在通用的設計原則基礎上根據自身實際情況更加的細化和明確,從而更好的指導團隊的協同發展。比如阿里巴巴著名的《Java開發規範》,它已經成爲行業普遍的指導性開發規範。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/95/95be96d34df26576005aa90d99de006b.png","alt":"架構設計原則","title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"我總結了一些架構方面的設計原則,如果有需要的朋友,可以關注我公衆號,私信“設計原則”給我。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"小結"}]},{"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":"所以,很多人認爲我學習了那麼多的技術,會各種各樣的技巧,爲什麼還不能成爲合格的架構師,其原因就是“術”與“器”都是小乘,而“道”與“法”纔是架構的上乘,正如老子所說:“道法自然”,架構之道,架構之法以架構的自然規律爲核心,也符合上文所說的“有據可依”,所以才能做出更好的架構決策。"}]},{"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":"但是學習設計原則,又千萬不能形成強迫症。碰到業務複雜的場景,我們需要隨機應變。在實際開發過程中,並不是一定要求所有代碼都遵循設計原則,我們要考慮人力、時間、成本、質量,不是刻意追求完美,要在適當的場景遵循設計原則,體現的是一種平衡取捨,幫助我們設計出更加優雅的代碼結構,做出更加適合自己的架構決策,適合的纔是最好的。"}]},{"type":"horizontalrule"},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ac/ac69e5756074418175395698868c9751.jpeg?x-oss-process=image/resize,p_80/auto-orient,1","alt":null,"title":null,"style":null,"href":null,"fromPaste":true,"pastePass":false}},{"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":""}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"《程序員的思維修煉》"},{"type":"text","text":"是菜根老譚結合自己的工作經歷和對這個崗位發展的認知而專門開闢的一個專欄,旨在分析程序員的職業發展的過程中我們應該鍛鍊哪些思維意識,如何去合理正確的看待事物,如何形成適合自己發展的思維體系。本專欄既是對過去思考的總結,也是對自己發展所具備的能力的思考,希望這些內容能陪我成長,幫大家解疑答惑。"},{"type":"text","marks":[{"type":"strong"}],"text":"該專欄首發今日頭條,關注我的同名頭條號和微信公衆號獲取更及時的內容推薦。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章