Adaptive Code via C#
Agile coding withdesign patterns andSOLID principlesPUBLISHED BYMicrosoft pressA division of microsoft CorporationOne Microsoft WayRedmond, Washington 98052-6399Copyright 2014 by Gary McLean Hall. All rights reservedNo part of the contents of this book may be reproduced or transmitted in any form or by any means withoutthe written permission of the publisherLibrary of Congress Control Number: 2014943458SBN:978-0-7356-8320-4Printed and bound in the United states of americaFirst PrintingMicrosoft Press books are available through booksellers and distributors worldwide. If you need support relatedtothisbook,emailmicrosoftPressBookSupportatmspinput@microsoft.com.Pleasetelluswhatyouthinkofthisbookathttp://aka.ms/tellpressThis book is provided"as-is"and expresses the author's views and opinions. The views, opinions and informationexpressed in this book, including URL and other Internet website references, may change without noticeSome examples depicted herein are provided for illustration only and are fictitious. No real association orconnection is intended or should be inferredMicrosoftandthetrademarkslistedathttp://www.microsoft.comonthetrademarks"webpagearetrademarksof the microsoft group of companies. all other marks are property of their respective ownersAcquisitions Editor: Devon MusgraveDevelopmental Editor: Devon MusgraveProject Editor: Devon MusgraveEditorial Production: Online Training Solutions, InC(OTSI)Technical Reviewer: Jeremy JohnsonCopyeditor: Kathy Krause(OTSI)Indexer: Krista Wall (OTSl)Cover: twist Creative. Seattle and joel panchoFor amelia rose-GARY MCLEAN HALLThis page intentionally left blankContents at a glanceIntroductionPART IAN AGILE FOUNDATIONCHAPTER 1Introduction to scrumCHAPTER 2 Dependencies and layering43chaPTer 3Interfaces and design patterns93CHAPTER 4Unit testing and refactoring125PART IWRITING SOLID CODECHAPTER 5 The single responsibility principle169CHAPTER 6 The open/closed principle207CHAPTER 7 The Liskov substitution principleChAPTeR 8Interface segregation251CHAPTER9 Dependency injection281PARTⅢADAPTIVE SAMPLECHAPTER 10 Adaptive sample: Introduction325CHAPTER 11 Adaptive sample: Sprint 1337CHAPTER 12 Adaptive sample: Sprint 2365Appendix A: Adaptive tools379Appendix B: GitHub code samplesonlineIndex387About the quthor403This page intentionally left blankContentsIntroductionPART IAN AGILE FOUNDATIONChapter 1 Introduction to ScrumScrum versus waterfall4Roles and responsibiliti7Product ownerScrum masterDevelopment team8Pigs and chickenArtifactsThe Scrum boardCharts and metrics22Backlogs27The sprint28Release planningSprint planning..30Daily scrumSprint demSprint retrospectiveScrum calendar36Problems with Scrum and agileMaladaptive cod37ConclusionThat do you think of this book? We want to hear from you!Microsoft is interested in hearing your feedback so we can continually improve ourbooks and learning resources for you. To participate in a brief online survey, please visitmicrosoft. com/learning/booksurveyvChapter 2 Dependencies and layering43The definition of dependency44A simpleple44Modeling dependencies in a directed graph51Managing dependImplementations versus intertThe new code smell...57Alternatives to object construction60The entourage anti-patternThe Stairway pattern65Resolving dependenciesependency management with NuGet77Layering81Common patterns82Cross-cutting concernsAsymmetric layeringConclusion91Chapter 3 Interfaces and design patterns93What is an interface?94Explicit implementation97polymorph101Adaptive design patterns102The Null Object pattThe Adapter pattern109The Strategy pattern111Further versatiDuck-typingIXIns118Fluent interfaConclusion124T ContentsChapter 4 Unit testing and refactoring125Unit testing125Arrange, act, Assert126Test-driven development130More complex tests135Refactoring...151Changing existing code151A new account type...160Conclusion165PARTⅢWRITING SOLID CODEChapter 5 The single responsibility principle169Problem statementRefactoring for clarity172Refactoring for abstraction177SRP and the decorator pattern184The composite pattern185Predicate decorators189Branching decoratorsLazy decorators194Logging decorators195Profiling decora196Asynchronous decorators200Decorating properties and events203Using the Strategy pattern instead of switch204Conclusion206
暂无评论