You are previewing Adaptive Code via C#: Agile coding with design patterns and SOLID principles.
O'Reilly logo
Adaptive Code via C#: Agile coding with design patterns and SOLID principles

Book Description

Agile coding with design patterns and SOLID principles

As every developer knows, requirements are subject to change. But when you build adaptability into your code, you can respond to change more easily and avoid disruptive rework. Focusing on Agile programming, this book describes the best practices, principles, and patterns that enable you to create flexible, adaptive code--and deliver better business value.

Expert guidance to bridge the gap between theory and practice 

  • Get grounded in Scrum: artifacts, roles, metrics, phases 

  • Organize and manage architectural dependencies 

  • Review best practices for patterns and anti-patterns 

  • Master SOLID principles: single-responsibility, open/closed, Liskov substitution 

  • Manage the versatility of interfaces for adaptive code 

  • Perform unit testing and refactoring in tandem 

  • See how delegation and abstraction impact code adaptability 

  • Learn best ways to implement dependency interjection 

  • Apply what you learn to a pragmatic, agile coding project

  • Get code samples at:

    http://github.com/garymclean/AdaptiveCode

    Table of Contents

    1. Title Page
    2. Copyright Page
    3. Dedication Page
    4. Contents at a glance
    5. Contents
    6. Introduction
      1. Who should read this book
        1. Assumptions
      2. This book might not be for you if...
      3. Organization of this book
        1. Part I: An Agile foundation
        2. Part II: Writing SOLID code
        3. Part III: Adaptive sample
        4. Appendices
      4. Conventions and features in this book
        1. Code listings
        2. Readeraids and sidebars
        3. Images
      5. System requirements
      6. Downloads: Code samples
      7. Acknowledgments
      8. Errata, updates, & book support
      9. Free ebooks from Microsoft Press
      10. We want to hear from you
      11. Stay in touch
    7. Part I: An Agile foundation
      1. Chapter 1. Introduction to Scrum
        1. Scrum versus waterfall
        2. Roles and responsibilities
          1. Product owner
          2. Scrum master
          3. Development team
          4. Pigs and chickens
        3. Artifacts
          1. The Scrum board
          2. Charts and metrics
          3. Backlogs
        4. The sprint
          1. Release planning
          2. Sprint planning
          3. Daily Scrum
          4. Sprint demo
          5. Sprint retrospective
          6. Scrum calendar
        5. Problems with Scrum and Agile
          1. Maladaptive code
        6. Conclusion
      2. Chapter 2. Dependencies and layering
        1. The definition of dependency
          1. A simple example
          2. Modeling dependencies in a directed graph
        2. Managing dependencies
          1. Implementations versus interfaces
          2. The new code smell
          3. Alternatives to object construction
          4. The Entourage anti-pattern
          5. The Stairway pattern
          6. Resolving dependencies
          7. Dependency management with NuGet
        3. Layering
          1. Common patterns
          2. Cross-cutting concerns
          3. Asymmetric layering
        4. Conclusion
      3. Chapter 3. Interfaces and design patterns
        1. What is an interface?
          1. Syntax
          2. Explicit implementation
          3. Polymorphism
        2. Adaptive design patterns
          1. The Null Object pattern
          2. The Adapter pattern
          3. The Strategy pattern
        3. Further versatility
          1. Duck-typing
          2. Mixins
          3. Fluent interfaces
        4. Conclusion
      4. Chapter 4. Unit testing and refactoring
        1. Unit testing
          1. Arrange, Act, Assert
          2. Test-driven development
          3. More complex tests
        2. Refactoring
          1. Changing existing code
          2. A new account type
        3. Conclusion
    8. Part II: Writing SOLID code
      1. Chapter 5. The single responsibility principle
        1. Problem statement
          1. Refactoring for clarity
          2. Refactoring for abstraction
        2. SRP and the Decorator pattern
          1. The Composite pattern
          2. Predicate decorators
          3. Branching decorators
          4. Lazy decorators
          5. Logging decorators
          6. Profiling decorators
          7. Asynchronous decorators
          8. Decorating properties and events
        3. Using the Strategy pattern instead of switch
        4. Conclusion
      2. Chapter 6. The open/closed principle
        1. Introduction to the open/closed principle
          1. The Meyer definition
          2. The Martin definition
          3. Bug fixes
          4. Client awareness
        2. Extension points
          1. Code without extension points
          2. Virtual methods
          3. Abstract methods
          4. Interface inheritance
          5. “Design for inheritance or prohibit it”
        3. Protected variation
          1. Predicted variation
          2. A stable interface
          3. Just enough adaptability
        4. Conclusion
      3. Chapter 7. The Liskov substitution principle
        1. Introduction to the Liskov substitution principle
          1. Formal definition
          2. LSP rules
        2. Contracts
          1. Preconditions
          2. Postconditions
          3. Data invariants
          4. Liskov contract rules
          5. Code contracts
        3. Covariance and contravariance
          1. Definitions
          2. Liskov type system rules
        4. Conclusion
      4. Chapter 8. Interface segregation
        1. A segregation example
          1. A simple CRUD interface
          2. Caching
          3. Multiple interface decoration
        2. Client construction
          1. Multiple implementations, multiple instances
          2. Single implementation, single instance
          3. The Interface Soup anti-pattern
        3. Splitting interfaces
          1. Client need
          2. Architectural need
          3. Single-method interfaces
        4. Conclusion
      5. Chapter 9. Dependency injection
        1. Humble beginnings
          1. The Task List application
          2. Constructing the object graph
          3. Inversion of Control
        2. Beyond simple injection
          1. The Service Locator anti-pattern
          2. Illegitimate Injection
          3. The composition root
          4. Convention over configuration
        3. Conclusion
    9. Part III: Adaptive sample
      1. Chapter 10. Adaptive sample: Introduction
        1. Trey Research
          1. The team
          2. The product
        2. Initial backlog
          1. Finding stories in prose
          2. Story point estimation
          3. Summary
      2. Chapter 11. Adaptive sample: Sprint 1
        1. Planning
        2. “I want to create rooms for categorizing conversations.”
          1. The controller
          2. The room repository
        3. “I want to view a list of rooms that represent conversations.”
        4. “I want to view the messages that have been sent to a room.“
        5. “I want to send plain text messages to other room members.”
        6. Sprint demo
          1. First demonstration of Proseware
        7. Sprint retrospective
          1. What went well?
          2. What went badly?
          3. Things to change?
          4. Things to keep?
          5. Surprises?
          6. Summary
      3. Chapter 12. Adaptive sample: Sprint 2
        1. Planning
        2. “I want to send markdown that will be correctly formatted.”
        3. “I want to filter message content so that it is appropriate.”
        4. “I want to serve hundreds of users concurrently.”
        5. Sprint demo
        6. Sprint retrospective
          1. What went well?
          2. What went badly?
          3. Things to change?
          4. Things to keep?
          5. Surprises?
          6. Summary
      4. Appendix A. Adaptive tools
        1. Source control with Git
          1. Git lessons
        2. Continuous integration
    10. Index
    11. About the author
    12. Back Cover
    13. Code Snippets