Design Patterns Tips

  • Chapter One:

    • The original fundamental design patterns were called GoF patterns
    • Don’t inherited unusable behavior or attribute
    • Identify the aspects of your application that vary and separate them from what stays the same
    • All design patterns provide a way to let some part of a system vary independently of all other parts
    • Assign the concrete implementation object at run time
    • Changing type at run time via interfaces (references)
    • Strategy Pattern: defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it
    • Patterns allow you to say more with less
    • One of the secrets to creating maintainable OO Systems is thinking about how they might change in the future
    • OO Principles:

      • Encapsulate what various
      • Favor composition over inheritance
      • Program to an interface not an implementation
    • Good OO designers are reusable, extensible and maintainable
    • Patterns don’t give you code; they give you general solutions to design problems. You apply them to your specific application
    • Patterns aren’t invented they are discovered
    • Patterns provide a shared language that can maximize the value of your communication with other developers
  • Chapter Two:

    • If you program for interface not implementation your code could be extendible dynamically
    • Publishers + Subscribers = Observer Pattern
    • Publisher is called SUBJECT and the subscribers are called OBSERVERS
    • You can find an OBJECT that also is an OBSERVER
    • Observer Pattern: defines one-to-many dependency between objects so that when one object changes state, all of it’s dependents are notified and updated automatically
    • Strive for loosely coupled designs between objects that interact
    • Loosely coupled designs allow us to build flexible OO systems that can handle change because they minimize the interdependency between objects
    • You can send the OBJECT in the update method in order to enhance any new measurements to the application
    • Don’t depend on a specific order of notification for your observers
    • OO Principles:

      • Strive for loosely coupled designs between objects that interact
  • Chapter Three:

  • Classes should be open for extension and closed for modifications
  • Decorator Pattern:

  • Attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality
  • Decorators have the same supertype as the objects they decorate.
  • You can use one or more decorators to wrap an object
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s