Browsing articles in "Programming"
Aug
23
2010

Design Patterns : Flyweight pattern

Flyweight Pattern

Motivation There are cases in programming where it seems that you need to generate a very large number of small class instances to represent data. Sometimes you can greatly reduce the number of different classes that you need to instantiate if you can recognize that the instances are fundamentally the same except for a few parameters. Intent Use sharing to support large numbers of fine-grained objects efficiently. Applicability Use flyweight pattern when An application uses [...]

Aug
18
2010

Design Patterns : Singleton

Singalton Pattern

Motivation It is important for some classes to have exactly one instance. As an example although there can be many printers in a system, there should be only one printer spooler. How do we ensure that a class has only one instance and that the instance is easily accessible within the network? Intent To ensure that a class has only one instance, and to provide a global point of access to it. Regardless of the [...]

Aug
16
2010

Design Patterns : Chain of Responsibility

Chain of Responsibility

Motivation Object-oriented developers strive to keep object loosely coupled, keeping the responsibility between objects specific and minimal.. This leads to introduce a change easily with less risk of defects. Clients see only an object’s visible interface and remain isolated from the details of the object’s implementation.   Intent Avoid coupling the sender of a request to its receiver by giving more than one object the chance to handle the request. To apply this pattern, chain [...]

Aug
14
2010

Design Patterns : Observer Pattern

Observer Pattern

Definition Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. Applicability Use Observer pattern when An abstraction has two aspects, one dependent on the other. Encapsulating these aspects in separate objects let you vary and reuse them independently. A change to one object requires changing others, and you don’t know how many objects need to be changed. An object should be able to [...]

Aug
12
2010

Design Patterns : Factory Method

Factory method

Motivation As a class developer, you will ordinarily provide class constructors to let users of your class instantiate it. However, a client that needs an object does not or should not know which of several possible classes to instantiate.   Intent Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.   Applicability Use Factory Method pattern when • In order [...]

Pages:«123456»