1. 程式人生 > >Agile Software Development 敏捷軟體開發

Agile Software Development 敏捷軟體開發

敏捷是什麼

  敏捷開發是一種軟體開發方法,基於迭代和增量開發,通過自組織,跨團隊,溝通協作完成開發工作。

敏捷宣言的誕生

2001年2月11日到13日,17位軟體開發領域的領軍人物聚集在美國猶他州的滑雪勝地雪鳥(SnowBird)雪場。經過兩天的討論,“敏捷”(Agile)這個詞為全體聚會者所接受,用以概括一套全新的軟體開發價值觀。這套價值觀,通過一份簡明扼要的《敏捷宣言》,傳遞給世界,宣告了敏捷開發運動的開始。

敏捷開發宣言內容

  我們一直在實踐中探尋更好的軟體開發方法,身體力行的同時也幫助他人。由此我們建立了如下價值觀:

  個體和互動   高於 流程和工具

  工作的軟體

   高於 詳盡的文件

  客戶合作     高於 合同談判

  響應變化     高於 遵循計劃

  也就是說,儘管右項有其價值,我們更重視左項的價值

英文原文:

  We are uncovering better ways of developing software by doing it and helping others do it. Through this work we have come to value:    Individuals and interactions over processes and tools    Working software over comprehensive documentation    Customer collaboration over contract negotiation    Responding to change over following a plan    That is, while there is value in the items on the right, we value the items on the left more.

敏捷開發的12條準則

準則1:

  Our highest priority is to satisfy the customer through early and continuous delivery of valuable software.    我們的最高目標是,通過儘早和持續地交付有價值的軟體來滿足客戶。 

準則2:

  Welcome changing requirements, even late in development. Agile processes harness change for the customer's competitive advantage.    歡迎對需求提出變更——即使是在專案開發後期。要善於利用需求變更,幫助客戶獲得競爭優勢。 

準則3:  

  Deliver working software frequently, from a couple of weeks to a couple of mouths, with a preference for the shorter timescale.    要不斷交付可用的軟體,週期從幾周到幾個月不等,且越短越好。 

準則4:  

  Business people and developers must work together daily throughout the project.    專案過程中,業務人員與開發人員必須在一起工作。 

準則5:  

  Build projects around motivated individuals. Give them the environment and support they need, and  trust them to get the job done.     要善於激勵專案人員,給他們以所需要的環境和支援,並相信他們能夠完成任務。 

準則6:  

  The most efficient and effective method of conveying information to and within a development team is face-to-face conversation.    無論是團隊內還是團隊間,最有效的溝通方法是面對面的交談。 

準則7:  

  Working software is the primary measure of progress.    可用的軟體是衡量進度的主要指標。 

準則8:  

  Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely.    敏捷過程提倡可持續的開發。專案方、開發人員和使用者應該能夠保持恆久穩定的進展速度。 

準則9:  

  Continuous attention to technical excellence and good design enhances agility.    對技術的精益求精以及對設計的不斷完善將提升敏捷性。 

準則10:  

  Simplicity -- the art of maximizing the amount of work not done -- is essential.    要做到簡潔,即盡最大可能減少不必要的工作。這是一門藝術。 

準則11:

  The best architectures, requirements, and designs emerge from self-organizing teams.     最佳的架構、需求和設計出自於自組織的團隊。 

準則12:  

  At regular intervals, the team reflects on how to become more effective, then tunes and adjusts its behavior accordingly.     團隊要定期反省如何能夠做到更有效,並相應地調整團隊的行為。

敏捷方法之Scrum

  Scrum Role 角色:

    Product Owner, Team, Scrum Master, Chicken and the Pig

    產品經理,團隊,Scrum Master,雞和豬,有一則小故事如下:

一隻雞對一頭豬說:“我們合夥開家飯店吧!”豬想了想,說:“那我們給這個飯店起什麼名字呢?”雞說:“雞蛋和火腿!”豬回答到:“那還是算了吧,你要做的只是下幾隻雞蛋,我把命都搭上了!”

  Scrum Meetings

  ① Sprint 計劃會議(Sprint Planning Meeting)

  需求澄清,確定那些使用者故事需要在接下來的迭代裡完成

  根據Product Owner制定的產品或專案計劃在Sprint的開始時做準備工作。

  他要準備一個根據商業價值排好序的客戶需求列表。這個列表就是Prodct Backlog[需求池],一個最終會交付給客戶的產品特性列表,它們根據商業價值來排列優先順序。

  商業價值"公式":As a <type of user> I want <some functionality> so that <some benefit>

Sprint Planning

  ② 每日站立會議(Daliy Meeting)

  在會議上每個團隊成員回答三個問題(During the meeting, each team member answers three questions)

  1. 昨天你完成了那些工作?(What have you done since yesterday?)

  2. 今天天你打算做什麼?(What are you planning to do today?)

  3. 完成你的目標是否存在障礙?(Do you have any problems that would prevent you from accomplishing your goal?)

  會議準時舉行(The meeting starts precisely on time.)

  任何人都可以參加,但只有團隊內部人員發言(All are welcome, but normally only the core roles speak.)

  會議時長限制為15分鐘(The meeting is timeboxed to 15 minutes.)

  會議時間地點應該固定(The meeting should happen at the same location and same time every day)

Daily Scrum

  ③ 評審會議(Sprint Review Meeting)

  評審會議在每個迭代結束後舉行,在會議上團隊演示此次迭代中完成了那些工作,一般會有相關的DEMO演示。   At the end of each sprint a sprint review meeting is held. During this meeting the Scrum team shows what they accomplished during the sprint. Typically this takes the form of a demo of the new features.

  這個會議演示的內容應該是啟動會議上確定的那些內容。

  During the sprint review the project is assessed against the sprint goal determined during the Sprint planning meeting.

Sprint Review Meeting

  ④ 回顧會議(Sprint Retrospective Meeting)

  衝刺回顧會議一般限時為3個小時(The sprint retrospective meeting is timeboxed to 3 hours.)

  僅團隊成員參加,產品經理和Scrum Master,產品經理可以選擇性參加(It is attended only by the team, the scrum master and the product owner. The product owner is optional.)。

  會議上團隊中每個成員需要回答兩個問題(Start the meeting by having all team members answer two questions):

  1. 此次衝刺中那些地方做得好?(What went well during the sprint?)

  2. 下個迭代中那些地方可以改進? (What could be improved in the next sprint?)

  Scrum Master 記錄每個成員的答案(The scrum master writes down the team’s answers in summary form)。

  團隊為這些改進意見評定優先順序(The team prioritizes in which order it wants to talk about the potential improvements)。

  Scrum Master在回顧會議中不允許給出答案,但要鼓勵成員自己找到較好的辦法(The scrum master is not in this meeting to provide answers, but to facilitate the team’s search for better ways for the scrum process to work for it)。

  這些改進工作可以新增至下個迭代中,作為一個非功能性工作,回顧會議最不擔心的就是變化(Actionable items that can be added to the next sprint should be devised as high-priority non functional product backlog. Retrospectives that dont result in change are sterile and frustrating.)。

Sprint Retrospective Meeting

測試驅動開發(TDD/Test-Driven Development)

測試驅動開發不是指測試人員驅動開發人員搞開發,一開始我真這麼認為了,實際上測試驅動開發指:

  以測試用例為出發點,不寫一行程式碼的情況下,編寫單元測試,從而無法通過,然後開始編寫程式碼使之通過測試。

  這樣做的好處是直指目標,達到目標被視一最高優先順序,TDD的執行離不開重構,因為這種開發方式完全漠視設計。

  所以設計在開始時一定很差,通過不斷的重構達到最優的程式碼,絕不會過度設計,也不會做偏。

  網上多半會說實踐後你會喜歡上它,它的大概流程如下圖所示:

Test-Driven Development

極限程式設計XP

XP是一個輕量級的、靈巧的軟體開發方法;同時它也是一個非常嚴謹和周密的方法。它的基礎和價值觀是交流、樸素、反饋和勇氣;即,任何一個軟體專案都可以從四個方面入手進行改善:加強交流;從簡單做起;尋求反饋;勇於實事求是。XP是一種近螺旋式的開發方法,它將複雜的開發過程分解為一個個相對比較簡單的小週期;通過積極的交流、反饋以及其它一系列的方法,開發人員和客戶可以非常清楚開發進度、變化、待解決的問題和潛在的困難等,並根據實際情況及時地調整開發過程。

結隊程式設計Pairng Program - 即時反饋

  流模式(Flow)— 兩個程式設計師共同從事一個有趣又有挑戰性的問題。

  指導模式(Coaching)— 老練的程式設計師在解決問題方面有經驗和知識,可以與其他不能有效地獨自解決問題的程式設計師分享。

Pairing Program

看板 - 工作視覺化,專注於當下

ToDo,OnGoing,Done,Impediment

Kanban

燃盡圖 Burn down 

燃盡圖是當前SPRINT工作進度的圖表,展示了還有哪些工作未完成,每天都會更新,它簡單的展示了工作進度,非常直觀。實事上還有其它類似的圖表,如釋出燃盡圖等。大概長什麼樣子呢?請瞧下圖:

Sprint Burn Down

英文原文:

  The sprint burn down chart is a publicly displayed chart showing remaining work in the sprint backlog. Updated every day, it gives a simple view of the sprint progress. It also provides quick visualizations for reference. There are also other types of burndown, for example the release burndown chart that shows the amount of work left to complete the target commitment for a Product Release (normally spanning through multiple iterations) and the alternative release burndown chart,[14] which basically does the same, but clearly shows scope changes to Release Content, by resetting the baseline. It should not be confused with an earned value chart. 

敏捷估算撲克 - 合理的任務分解 

  敏捷方法中的估算應該是由團隊成員共同進行,而不是由專案經理“閉門造車”式地得出。這樣做的原因之一是因為開發團隊是由不同經驗的同事組成,對於同一個問題,經驗不同的人往往會給出不一樣的解決方案。如果可以將所有人的能力集中到一起,那麼最後對問題的求解也就八九不離十了。

Scrum Poker

持續整合(Continuous Integration)- 團隊協作的基礎

  什麼是持續整合(Continuous Integration)?

  這個名詞已經在軟體開發領域持續了N年,一個比較簡單的定義如下:

持續整合(CI)是一種實踐,可以讓團隊在持續釋出的基礎上收到反饋並進行改進,不必等到開發週期後期才尋找和修復缺陷。

CI

單元測試 Unit Test - 重構的保障

  單元測試(模組測試)是開發者編寫的一小段程式碼,用於檢驗被測程式碼的一個很小的、很明確的功能是否正確。

  通常而言,一個單元測試是用於判斷某個特定條件(或者場景)下某個特定函式的行為。

敏捷測試 Agile Test

  所謂敏捷測試,就是指測試遵循敏捷宣言進行,把開發作為顧客看待。與敏捷宣言中的“個體和互動比過程和工具更有價值”一樣強調人的作用。

程式碼重構 Reconstruction

Duplicated Code(重複程式碼)

Long Method(過長函式)

Large Class(過大的類)

Long Parameter List(過長引數列)

Divergent Change(發散式變化)

Shotgun Surgery(霰彈式修改)

Feature Envy(依戀情結)

Data Clumps(資料泥團)

Primitive Obsession(基本型別偏執)

Switch Statements(switch驚悚現身)

Parallel InheritanceHierarchies(平行繼承體系)

Lazy Class(冗贅類)

Speculative Generality(誇誇其談未來性)

Temporary Field(令人迷惑的暫時欄位)

Message Chains(過度耦合的訊息鏈)

Middle Man(中間人)

Inappropriate Intimacy(狎暱關係)

Alternative Classes with Different Interfaces(異曲同工的類)

Incomplete Library Class(不完美的庫類)

Data Class(純稚的資料類)

Refused Bequest(被拒絕的遺贈)

Comments(過多的註釋)

Extract Method(提煉函式)

Inline Method(行內函數)

Inline Temp(內聯臨時變數)

Replace Temp with Query(以查詢取代臨時變數)

Introduce Explaining Variable(引入解釋性變數)

Split Temporary Variable(分解臨時變數)

Remove Assignments to Parameters(移除對引數的賦值)

Replace Method with Method Object(以函式物件取代函式)

Substitute Algorithm(替換演算法)

Move Method(搬移函式)

Move Field(搬移欄位)

Extract Class(提煉類)

Inline Class(將類內聯化)

Hide Delegate(隱藏"委託關係")

Remove Middle Man(移除中間人)

Introduce Foreign Method(引入外加函式)

Introduce Local Extension(引入本地擴充套件)

Self Encapsulate Field(自封裝欄位)

Replace Data Value with Object(以物件取代資料值)

Change Value to Reference(將值物件改為引用物件)

Change Reference to Value(將引用物件改為值物件)

Replace Array with Object(以物件取代陣列)

Duplicate Observed Data(複製"被監視資料")

Change Unidirectional Association to Bidirectional(將單向關聯改為雙向關聯)

Change Bidirectional Association to Unidirectional(將雙向關聯改為單向關聯)

Replace Magic Number with Symbolic Constant(以字面常量取代魔法數)

Encapsulate Field(封裝欄位)

Encapsulate Collection(封裝集合)

Replace Record with Data Class(以資料類取代記錄)

Replace Type Code with Class(以類取代型別碼)

Replace Type Code with Subclasses(以子類取代型別碼)

Replace Type Code with State/Strategy(以State/Strategy取代型別碼)

Replace Subclass with Fields(以欄位取代子類)

Decompose Conditional(分解條件表示式)

Consolidate Conditional Expression(合併條件表示式)

Consolidate Duplicate Conditional Fragments(合併重複的條件片段)

Remove Control Flag(移除控制標記)

Replace Nested Conditional with Guard Clauses(以衛語句取代巢狀條件表示式)

Replace Conditional with Polymorphism(以多型取代條件表示式)

Introduce Null Object(引入Null物件)

Introduce Assertion(引入斷言)

Rename Method(函式改名)

Add Parameter(新增引數)

Remove Parameter(移除引數)

Separate Query from Modifier(將查詢函式和修改函式分離)

Parameterize Method(令函式攜帶引數)

Replace Parameter with Explicit Methods(以明確函式取代引數)

Preserve Whole Object(保持物件完整)

Replace Parameter with Methods(以函式取代引數)

Introduce Parameter Object(引入引數物件)

Remove Setting Method(移除設值函式)

Hide Method(隱藏函式)

Replace Constructor with Factory Method(以工廠函式取代建構函式)

Encapsulate Downcast(封裝向下轉型)

Replace Error Code with Exception(以異常取代錯誤碼)

Replace Exception with Test(以測試取代異常)

Pull Up Field(欄位上移)

Pull Up Method(函式上移)

Pull Up Constructor Body(建構函式本體上移)

Push Down Method(函式下移)

Push Down Field(欄位下移)

Extract Subclass(提煉子類)

Extract Superclass(提煉超類)

Extract Interface(提煉介面)

Collapse Hierarchy(摺疊繼承體系)

Form Tem Plate Method(塑造模板函式)

Replace Inheritance with Delegation(以委託取代繼承)

Replace Delegation with Inheritance(以繼承取代委託)

Tease Apart Inheritance(梳理並分解繼承體系)

Convert Procedural Design to Objects(將過程化設計轉化為物件設計)

Separate Domain from Presentation(將領域和表述/顯示分離)

Extract Hierarchy(提煉繼承體系)

程式碼 Code Review

不想重複說了,同單元測試一樣重要。

  Code Review

總結

以上是個人經過理論學習,實踐檢驗後總結的一篇文章,其中大部分觀點、素材皆來自網路和公司敏捷活動中所得。我想要說的是,我是支援這些觀點的,我認為這些方法論可以很好的指導日常開發工作,能夠解決實際問題,That's All。