Monday, June 15, 2015

Interfaces and Design Patterns



Null Object Pattern: Its purpose is to allow you to avoid accidentally throwing a NullReferenceException and a plethora of null object checking code

The isNull Anti Pattern : Sometimes the Null Object pattern involves adding a Boolean IsNull property to the interface(IAbstraction). All real implementations(real object ) of this interface return the value false for this property. The Null Object implementation of the interface returns true.

The Adapter pattern : The Adapter pattern allows you to provide an object instance to a client that has a dependency on an interface that your instance does not implement. An Adapter class is created that fulfills the expected interface of the client but that implements the methods of the interface by delegating to different The Class Adapter pattern methods of another object. It is typically used when the target class cannot be altered to fit the desired interface. This could be because it is sealed or because it belongs to an assembly for which you do not have the source.
The Class Adapter pattern :

The object adapter pattern :
The strategy pattern: The Strategy pattern is used whenever a class needs to exhibit variant behavior depending on the state of an object. If this behavior can change at run time depending on the current state of the class.
the Strategy pattern is a perfect fit for encapsulating this variant behavior.










No comments:

Post a Comment