• Implementing an interface allows a class to become more formal about the behavior it promises to provide
• Interfaces form a contract between the class and the outside world, and the contract is enforced at build time by the compiler
• If a class implements an interface it must implement all the methods the implemented interface defines
• All the methods and properties defined in Interface are by default public and abstract
Friday, August 10, 2007
Design Pattern > Behavioural > Observer
Design Pattern > Structural > Iterator
ITERATOR PATTERN
• Iterator pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying operations
• In .net System.Collection assembly classes support all the functionality of the iterator pattern through a call to GetEnumerator(), which returns a concrete iterator, the Ienumerator interface
• Iterator pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying operations
• In .net System.Collection assembly classes support all the functionality of the iterator pattern through a call to GetEnumerator(), which returns a concrete iterator, the Ienumerator interface
Design Pattern > Structural > Proxy
Design Pattern > Structural > Facade
FACADE PATTERN
• Provides a unified interface to a set of interfaces in a subsystem
• Facade defines a higher level interface that makes the subsystem easier to use
• Facade knows which subsystem classes are responsible for a request
• Delegates client requests to appropriate subsystem objects
• In coding prespective, Facade class holds objects of all the subsystems under it
• Provides a unified interface to a set of interfaces in a subsystem
• Facade defines a higher level interface that makes the subsystem easier to use
• Facade knows which subsystem classes are responsible for a request
• Delegates client requests to appropriate subsystem objects
• In coding prespective, Facade class holds objects of all the subsystems under it
Design Pattern > Creational > Factory

• A Factory Pattern is one that returns an instance of one of several possible classes depending on the data provided to it
• Usually all the classes it returns should have a common base class and common methods, but implementations of the methods may be different
• Following is an UML representation of the Factory Method Pattern. Note that no instances of Class derived1 or derived2 are directly created
• Factory class’ doIt() method is used to get the objects, and object type is determined on the basis of information passed to getObject() method
Design Pattern > Creational > Singleton
SINGLETON
• Singleton design pattern is used when only one instance of an object is needed throughout the lifetime of an application
• The Singleton Class is instantiated at the time of first access and the same instance is used thereafter till the application quits
• Singleton Class can be used in various places where one would need a common repository of information that can be accessed from all objects in an application
• For example sometimes only a single database connection object or network connection object may be needed by the application
• Singleton design pattern is used when only one instance of an object is needed throughout the lifetime of an application
• The Singleton Class is instantiated at the time of first access and the same instance is used thereafter till the application quits
• Singleton Class can be used in various places where one would need a common repository of information that can be accessed from all objects in an application
• For example sometimes only a single database connection object or network connection object may be needed by the application
Subscribe to:
Posts (Atom)