Applying Design Patterns to Solve Everyday Problems

Applying Design Patterns to Solve Everyday Problems

Applying Design Patterns to Solve Everyday Problems David Berry @DavidCBerry13 http://buildingbettersoftware.blogspot.com https://github.com/DavidCBerry13/DesignPatternsCode/ What is a Design Pattern? Wikipedia - https://en.wikipedia.org/wiki/Software_design_pattern In software engineering, a software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system. What is a Design Pattern? Really? • Formalized, reusable solution to a common problem • An elegant solution with a well thought out design • Well understood by the software development community How Do I Learn About These Things? Books describe how to implement the different patterns, but it is often times difficult to know when to apply them Isolation From Dependencies Our Code Interface Dependency Two Patterns Used Together Bridge Pattern Adapter Pattern • Uses an interface to isolate your • Converts the interface of an code from different implementations existing class to another interface • Allows you to easily switch out • Used to make an existing class implementations behind the work with others without bridge needing to change the source • Allows code to be tested without code the dependency • Sets us up to use dependency injection Solution Diagram Decorator • Effectively wraps one object inside of Decorator another • Decorator objects implement the Decorator same interface as the object they are decorating • Allows you to add behavior without modifying the original object Object • Objects can be decorated multiple times • Useful for cross cutting concerns Decorator Decorator Decorator Object Method Method Method Method Method Method Calling Calling Code Method Method Method Allows you to intercept calls for the wrapped object (both inbound and outbound) Chain of Responsibility Payment • Think of a series of multiple Data CreditCardPaymentTypeHandler handlers that can each handle a request • Each handler is focused on a single use case EftPaymentTypeHandler • If a handler cannot process the Falls through request, it passes the request to until handled the next handler in the chain CheckPaymentTypeHandler • Order can be important (depending on your use case) Base class provides the algorithm template Template Pattern Template Child classes provide implementation details in their methods Resources • Head First Design Patterns (Book) • http://shop.oreilly.com/product/9780596007126.do • Design Patterns On-Ramp (Pluralsight Course) • https://www.pluralsight.com/courses/design-patterns-on-ramp • C# Interfaces (Pluralsight Course) • https://www.pluralsight.com/courses/csharp-interfaces • Design Patterns Library (Pluralsight Course) • https://www.pluralsight.com/courses/patterns-library.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us