490 likes | 662 Views
Managing Technical Debt. Pierre G. Boutquin. Welcome!. Welcome to the Toronto ALM User Group “TALMUG”. Thank You, Sponsors!. Agenda or Summary Layout. Intro. Part I. Part II. Choosing or Not Choosing Technical Debt. A second line of text could go here. Agenda; TALMUG; Me.
E N D
Managing Technical Debt Pierre G. Boutquin
Welcome! Welcome to the Toronto ALM User Group“TALMUG”
Agenda or Summary Layout Intro Part I Part II Choosing or Not Choosing Technical Debt A second line of text could go here Agenda; TALMUG; Me Debt Characteristics Discovering and Preventing Technical Debt Discussion Part III End ???
About Me Work Experience
About Me Programming Experience
About Me Author
Under Promising… About today’s talk…
History of a Metaphor 1992 Ward Cunningham
Debt: Good or Bad? Depends… • Deliberate vs. Inadvertent • Prudent vs. Reckless http://martinfowler.com/bliki/TechnicalDebtQuadrant.html
Why Debt? Trade-Off… • Faster Short Term Benefit • Extra Cost
Debt Drawback Principal/Interest • Extra Cost (Interest) • As Long as Debt (Principal) NOT Paid Off
Unmanaged Debt Aka My Credit Card • Perpetual Debt • Growing Interest
Incurring Debt Reckless vs. Prudent • Deliberate Trade-Off: Maybe Prudent • Inadvertent Debt: Likely Reckless
Deliberate Debt When Prudent? • Benefits Outweigh Extra Costs • Affordable Repayment Plan
Acceptable Debt 4 Criteria: • Deliberate Decision • Positive Cost/Benefit • Planned, Affordable Repayment • Prudent Total Debt
Unwise Debt 4 Tell-Tale Signs • Inadvertent Decision • Negative or Small Cost/Benefit • Repayment Not Planned/Too High • Reckless Total Debt
PART I - Conclusion Debt Criteria: • Total Level of Deliberateness • Size of Cost/Benefit • Affordability of Repayment • Total Debt Load
Part II: Deliberate Technical Debt Choosing or Not Choosing Debt…
Deliberate Technical Debt Why??? • Good: Deliver Early/On Time • Bad: Detestable Code • Ugly: The Spike
Deliberate Technical Debt Avoidable? • Maybe: Date Driven Development • Yes: Feature Driven Development
Deliberate Technical Debt Date-Driven Project • Shipping Date is Fixed • Features Are Negotiable • Often Less Desirable
Deliberate Technical Debt Feature-Driven Project • Features Are Fixed • Shipping Date Is Negotiable • Often More Desirable
The MVP Concept “Minimal Viable Product” • Release Planning Tool • Combines Well With Prioritization
Prioritization Sometimes…
Prioritization Key: By Business Value • Agile/Scrum: Backlog • Traditional: Prioritization Needs Forethought
MoSCoW Prioritization • MUST: Part of MVP • SHOULD: High-Priority • COULD: Nice to Have • WOULD: Maybe Later
Part III: Minimizing Inadvertent Debt Discovering and Preventing Debt…
Minimizing: How? 2 Angles: • Process • Tools
Minimizing: How? Process vs. process • Process: SDLC • process: Engineering Practices • Test First Development
Minimizing: Type of Tools 2 Objectives: • Communications • Technical Excellence
Minimizing: Communication Tools Tools We Use: • Standup Meeting • Shared SME • Design Reviews • Code Reviews
Minimizing: Technical Tools Tools We Use: • Unit Tests • Code Contracts • Static Code Analysis • Adherence to Coding Standard • Good Coding Practices • Code Metrics
Tool: Unit Tests Recommended Book: “The Art of Unit Testing” http://www.manning.com/osherove2/
Tool: Unit Tests Roy Osherove’s Definition: • A Unit Test is an automated piece of code that invokes the unit of work being tested and then checks some assumptions about a single end result of that unit. • A unit test is almost always written using a unit-testing framework. It can be written easily and runs quickly.
Tool: Unit Tests Roy Osherove’s Definition (cont’d): • A Unit Test is trustworthy, readable and maintainable. It is consistent in its results as long as the production code has not changed.
Unit Test Tips: Naming Convention [UnitOfWork]_[Condition]_[ExpectedResult] • /// <summary> • /// This test demonstrates that constructor of • /// the <see cref="VenomSender" /> class is creating a topic session • /// when it is being given valid configuration. • /// </summary> • [TestMethod] • public voidConstructor_ValidTibcoConfig_ReturnsNonNullTopicSession() • { • // ARRANGE • var tibcoConfig = TestUtils.CreateValidTibcoConfig(); • // ACT • var venomSender = new VenomSender(tibcoConfig); • // ASSERT • Assert.IsNotNull(venomSender.TopicSession); • }
Unit Test Tips: Design Pattern Design Pattern: AAA • /// <summary> • /// This test demonstrates that constructor of • /// the <see cref="VenomSender" /> class is creating a topic session • /// when it is being given valid configuration. • /// </summary> • [TestMethod] • public voidConstructor_ValidTibcoConfig_ReturnsNonNullTopicSession() • { • // ARRANGE • var tibcoConfig = TestUtils.CreateValidTibcoConfig(); • // ACT • var venomSender = new VenomSender(tibcoConfig); • // ASSERT • Assert.IsNotNull(venomSender.TopicSession); • }
Unit Test Tips: Sad Paths Maintainability Tip: • Use Happy Path Factory Helper • Then, Create Single Sad Path • Test Both Exception Type & Message
Unit Test Tips: Sad Path Design Pattern: • /// <summary> • /// This test demonstrates that constructor of • /// the <see cref="VenomSender" /> class is throwing an exception • /// when it is being passed a null SslCertStoreName. • /// </summary> • [TestMethod] • public voidConstructor_nullSslCertStoreName_ThrowsException() • { • // ARRANGE • var tibcoConfig = TestUtils.CreateValidTibcoConfig(); • tibcoConfig.SslCertStoreName = null; • // ACT • var venomSender = new VenomSender(tibcoConfig); • // ASSERT • // etc, • }
Code Metrics Cyclomatic Complexity • Method-Level Measure • Calculated from Control Flow Graph • Smaller Values Better • <= 25 Acceptable
Code Metrics Maintainability Index • Synthesis of Three Metrics • Cyclomatic Complexity • Lines of Code • Computational Complexity • Icons Color-Coded • GREEN (>20) • YELLOW (10-20) • RED (<10) • Not Expressed in Units!
Code Contracts Now Part of .NET! • New to Me • No Best Practices To Share Yet…
Coding Standard The Final Word… • Partially Matter of Opinion • Let Tool Decide • StyleCop • ReSharper