I'm CaLendarW Blog

architecture

Great software is not built, it is grown

by calendarw on Jun.18, 2009, under architecture

作為一個架構師,主要任務是提供了初部結構和安排不段增長和隨著時間而改變的軟件系統,而且幾乎總是在你和利益相關者沒有預見下重做,或者和其他系統溝通。儘管我們是所謂的架構師,我們由建築和工程方面借用了許多隱喻,但偉大的軟件不是建造,而係成長出來的。

唯一最大既避免軟件失敗係軟件規模;由大型系統開始設計幾乎沒有任何好處。然而,在某個時候我們都將受到誘惑而這樣做。除了作為容易附帶的複雜性和慣性,設計大型系統的前期意味著更大的項目,這些項目更有可能失敗,更可能是無法測試,更可能是脆弱的,更可能有不必要的和不使用的部分,更可能是昂貴的,而且更有可能產生不利因素。

因此要抗拒試圖設計一個大型完整的系統,無論是多麼誘人,以“達到或超過”已知的要求和期望的特性。已經是一個宏大的目標,但不一定是一個大的設計。令你同你的系統學習適應環境及不可避免的改變。

如何做到這一點?最佳的途徑係從一開始確保軟件系統可以成長和適應不斷發展。誘導系統成長代表從一個較小的系統運行,做一部分架構既工作 – 做最簡單而最有可能完成的部份。這初生的的系統將有很多可取的性能和能教育我們了解更多大型系統的架構,或者更糟的一堆架構文件。你更有可能參與了其實現方法。而細小的介面將可更輕鬆地進行測試,因此不容易耦合。這只需要一個較小的團隊,間接降低協調項目的成本。而且其特性將會更容易被觀察,更輕鬆地部署。它會教你和你的團隊在最早的時刻知道什麼做到和什麼做不到。它會告訴你的系統不會容易發展、有可能是堅固、或者係脆弱、又或者有可能被破解。也許最重要的是可以從一開始給予利益相關者一些理解和確實的情況,使他們能夠為整體設計成長。

設計最小的系統,您可以幫助實現它,並讓它朝著宏偉構想。雖然這可能會覺得自己放棄了控制,甚至推卸的責任,最終您的利益相關者將會向你表示感謝。不要混淆循序漸進的辦法與不理要求,可怕的逐步,或建設一個將會扔掉的系統。

##############################################

As an architect you are tasked with providing the initial structure and arrangement of software systems that will grow and change over time, will have be to reworked, will have to talk to other systems, and almost always in ways you and your stakeholders did not foresee. Even though we are called architects, and we borrow many metaphors from building and engineering, great software is not built, it is grown.

The single biggest predictor of software failure is size; on reflection there’s almost no benefit to be had from starting with a large system design. Yet at some point we will all be tempted to do exactly that. As well as being prone to incidental complexity and inertia, designing large systems upfront means larger projects, which are more likely to fail, more likely to be un-testable, more likely to be fragile, more likely to have unneeded and unused parts, more likely to be expensive, and more likely to have a negative political dimension.

Therefore resist trying to design a large complete system to “meet or exceed” the known requirements and desired properties, no matter how tempting that might be. Have a grand vision, but not a grand design. Let you and your system learn to adapt as the situation and requirements inevitably change.

How to do this? The best way to ensure a software system can evolve and adapt is to evolve and adapt it from the very outset. Inducing a system to evolve means starting with a small running system, a working subset of the intended architecture – the simplest thing that could possibly work. This nascent system will have many desirable properties and can teach us much about the architecture that a large system, or worse, a collection of architectural documents never can. You are more likely to have been involved in its implementation. Its lack of surface area will be easier to test and therefore less prone to coupling. It will require a smaller team, which will reduce the cost of coordinating the project. Its properties will be easier to observe. It will be easier to deploy. It will teach you and your team at the earliest possible moment what does and does not work. It will tell you where the system will not evolve easily, where it is likely to crystallize, where it is fragile. Where it might break. Perhaps most important, it will be comprehensible and tangible to its stakeholders from the beginning, allowing them to grow into the overall design as well.

Design the smallest system you can, help deliver it, and let it evolve towards the grand vision. Although this might feel like giving up control, or even shirking your responsibilities, ultimately your stakeholders will thank you for it. Do not confuse an evolutionary approach with throwing requirements out, the dreaded phasing, or building one to throw away.

by Bill de hÓra (edited by RMH Sept. 26, 2008) in 97 Things Every Software Architect Should Know

This work is licensed under a Creative Commons Attribution 3

Leave a Comment : more...

Separation Of Concerns

by calendarw on Apr.26, 2009, under architecture, design

係軟件設計方面, 其實主要都想將唔同既 Concern 分開, 以我做開主要有以下幾個:

  • Flow / Business Logic
  • Input (Import Data, Interface for 3rd Party)
  • Output (User Interface, Report)
  • Database
  • Logging
  • Permission

在以上幾個 Concern 上, 而 Logging 同 Permission 呢兩樣野其實應該可以重用, 而且應該可以視為另一個軟件 / Domain Area.

Database 使用方面, 因為市面有不同種類既選擇, 而為左可以應用係唔同 Database 上, 好多人都會加上一個 Data Access Layer, 正常既 implement 手法都係 Object Relational Mapping, 在 .net 主要有 LGPL LicenseNHibernate, Castle Project 既Active Record, 又或者係 .net 3.5 既 Linq To SQLEntity Framework, 這些 Module 已經被外國引用成為主流, 因為使用者不用因應不同既 Database 而寫大同小異既 SQL, 避免了因小異而不段尋找問題, 只要學習一套, 其他由 OR Mapper 做便好了.

Logging 方面, Debug Log 其實可以用 Apache Licenselog4net, 而 Audit Log 我覺得應該可以視為另一個軟件而寫到一個 Lib 黎比全公司用, 以統一全公司軟件開發基礎.

Permission 方面主要有 AuthenticationAuthorization 兩個部份, 我覺得可以寫得開一個 Lib, 因應唔同需要 (e.g. 用 AD or 自己既 Login Table) 而各自使用同一個 Interface 既唔同 Implementation, 總好過不同 Project 都用緊不同既處理手法.

Input 同 Output 方面其實都幾難重用, 不過都應該可以寫到一 d 相對應既 Lib (e.g. Import/Export Excel, Customize User Control 或者既定的 3rd Party Solution).

Flow 其實係最難重用既部份, 因為應該唔同 Project 都有唔同既 Flow / Business Logic, 而常見既處理手法都會使用 Object Oriented Design, 而為了保證質素, 外國 (包括 Microsoft) 寫左套測試系統黎令做 Automate Testing, 有早期自己用開既 NUnit, 或者 Visual Studio 2005 打後既 Unit Testing Framework, 當然仲有好多其他既 Implementation, 只不過自己用開 NUnit 而無再留意.

綜合以上不同既 Concern, 其實除左 Flow/Business Logic, Input 同 Output 之外, 其他部份應該都可以重用, 如果每個 Project 都可以重用這些 Module, 寫軟件既時間應該可以集中一點在不能重用既部份而提高用家對軟件質素既評價, 亦可以有時間做 Performance Turning 及 Unit Testing, 使軟件能夠提升質量, 有關點解要 Testing 既資料可以參考舊 Post, 而 Performance Testing 其實亦可以靠 Unit Test 黎做監察 (詳見 Pragmatic Unit Testing in C# with NUnit 內有關 Performance Testing 一節)

重用既除左可以減少需要 Implement 既時間外, 對新人黎講都會容易跟, 因為套套系統都用緊同一樣野可以減省 Pickup 現有系統既時間. 不過對於重用方面, 公司既軟件管理政策亦同樣重要, 如果個個 Project 都係 Copy 一套出黎用, 那麼發現一個 Bug 就要搵晒全公司既所有 Project 一個個改, 這些處理手法在 AntiPattern 內亦有提及, 往往做成不良後果.

不過以上既推論都有重要既假設: 一個好既 OO Design 同 Design for Reuse. 如果設計得唔好, 就沒有人會用, 如果不是為重用而設計, 就不能重用.

對我在舊公司管理及維持左 Reusable Lib of Web Module, Data Module 同 Common Module 及不同 Internal Project 年幾時間既我, 加上接近七年前大專開始既軟件開發生涯, 在 OO Design 同 Design for Reuse 都自覺有相當既經驗, 雖然亦有好多不足既地方, 但亦希望跟住呢條路行. 而因未發新公司有現醒啱用既 Lib , 所以自己寫左一些重用到既 Lib, 加上 Project 開始繁忙而盡量希望在 Project 內實行軟件架構, 短期內應該有好多機會提升自己在設計及實行方面既經驗, 希望現實真係可以咁 Ideal 啦.

Leave a Comment :, more...

97 Things Every Software Architect Should Know

by calendarw on Mar.29, 2009, under architecture

近期睇緊 97 Things Every Software Architect Should Know 既 post, 入面有好多被公認 Software Architect 要知既事情, 我想如果要做到專業既話, 入面每一樣野都應該深入了解下!!!

除此之外, 仲有 Other Things Software Architect Should Know, 部份只有標題, 不過都理解到那些標題要深入研究的話係有難道的.

Leave a Comment more...

Object Relational Mapping 用後感

by calendarw on Mar.17, 2008, under architecture

自從轉左用 ORM 既 NHibernate, 以及公司某 Project 用左 Hibernate 之後, Overall 感覺都係慢既問題, Load 500 個 record 可能要成分鐘. 不過, 經我網上搵過既意見, 有部份人讚成用 ORM, 因為除左可以提升 program 既 simplicity 之外, man hour 係 develop 同 maintain 傳統 program 既時間同金錢, 應該遠比用 ORM Tool 既速度慢而買既 hardware cost 高, 所以如果要比較傳統既 SQL 方法同 ORM 黎講, 應該係後者會比較好.

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!