Sunday 9 February 2014

More Stuff

  1. Basic OO Principles
    1. Encapsulation
    2. Inheritance
    3. Polymorphism
    4. Abstraction
    5. Association
    6. Aggregation
    7. Composition
  2. OO Design Principles
    1. Single Responsibility Principle (SRP)
    2. Open/Closed Principle (OCP)
    3. Liskov Substitution Principle (LSP)
    4. Dependency Inversion Principle (DIP)
    5. Interface Segregation Principle (ISP)
    6. package cohesion group : the Reuse/Release Equivalency Principle (REP)
    7. package cohesion group : the Common Closure Principle (CCP)
    8. package cohesion group : the Common Reuse Principle (CRP)
    9. package coupling group : the Acyclic Dependency Principle (ADP)
    10. package coupling group : the Stable Dependency Principle (SDP)
    11. package coupling group : the Stable Abstractions Principle (SAP)
  3. Design Patterns
    1. Structural
      1. Decorator
      2. Proxy
      3. Bridge
      4. Composite
      5. Flyweight
      6. Adapter
      7. Facade
    2. Creational
      1. Prototype
      2. Factory Method
      3. Singleton
      4. Abstract Factory
      5. Builder
    3. Behavioural
      1. Strategy
      2. State
      3. Template
      4. Chain of responsibility
      5. Command
      6. Iterator
      7. Mediator
      8. Observer
      9. Visitor
      10. Interpreter
      11. Memento


51 patterns of enterprise application architecture identified by Martin 
Fowler et al., and 
65 enterprise integration patterns

Saturday 8 February 2014

Patterns

Decorator pattern

Use the decorator pattern when:
You have

  • - An existing component class that may be unavailable for subclassing


You want to
  • -Attach additioanl state or behaviour to an object dynamically (or remove it ?????????)
  • -make changes to some objects in a class without affecting others
  • -avoid subclassing because too many classes would result (hmmmmmmm, sounds like bullshit to me).

But consider using instead

  • -The Adapter pattern, which sets up an interface between different classes 
  • -The Composites patter, which aggregates an object without also inheriting its interface 
  • -The Proxy pattern, which specifically controls access to objects. 
  • -The Strategy pattern, which changes the original object rather than wrapping it.


example I/O Apis of C# , Stream, BufferedStream, FileStream, MemoryStream, NetworkStream, ,CryptoStream

  Proxy Pattern

 ADO.Net database connection classes are effectively proxies. Often found in image-drawing systems, where the proxy places a placeholder on the screen and then activates a real drawer to fetch and render the image. And similary to initiate the buffering associated with video streaming.

 Both the adapter and proxy patterns consitute a thin layer around an object. However the adapter provides a different interface for an object, while the proxy provides the same interface, but interposes itself where it can postpon processing or data transmission effort.

A decorator also has the same interface as the object it surrounds, but its purpose is to add additional funtoin to the original object. A proxy, by contrast, controls access to the contained class.

 Proxies like decorators forward requests on to another object. The proxy relationship is set up at design time (compile time) , decorators on the other hand can be added dynamically (what about dynamic proxies??????????).

 Remote
Virtual
Authentication
(Dynamic ??????????)

 Use the proxy pattern when you have objects that

  • -are expensive to create
  • -need access control
  • -access remote sites need to perform some action whenever they are accessed 

 you want to

  •  -create objects only when their operations are requested
  •  -perform checks or housekeeping on objects whenever accessed
  •  -have a local object that will refer to a remote object
  • -implement access rights on objects as their operations are requested


  Strategy Pattern 

 Use the strategy pattern when

  •  -Many classes differ only in their behaviour
  •  -There are different algorithms for a given purpose, and the selction criteria can be codified
  •  -The algorithm uses data which the client should not have access to (hmm, what does this mean????????????)


  Bridge Pattern

 Use the bridge pattern to vary not only your implementations but also your abstractions.

  Iterator Pattern

  Composite Pattern