Browsing articles by " hanxlk"
Sep
2
2010

Design Patterns : Iterator pattern

Iterator Pattern

What is iteration? In computer science, an iterator is an object which allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation. An iterator is sometimes called a cursor, especially within the context of a database. Intent Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. Diagram Applicability Use Iterator pattern To access an aggregate object’s contents without exposing its internal [...]

Aug
31
2010

Design Patterns : Builder pattern

Builder pattern

Motivation To reduce the size of a class that has many methods. Also to allow step-by-step construction of a target object. Intent Separate the construction of complex object from its representation so that the same construction process can create different representations. Diagram Applicability Use Builder pattern when; You want to vary the internal representation of the product it builds. It also hides the details of how the product is assembled. You want to construct the [...]

Aug
28
2010

Design Patterns : Facade pattern

Façade Pattern

Motivation Structuring a system in to subsystem helps reduce complexity. A common design goal is to minimize the commutation and dependencies between systems. One way to achieve this goal is to introduce a façade object that provides a single, simplified interface to the more general facilities of a subsystem. Intent Provide a unified interface to a set of interfaces in a Wrapper. Diagram Applicability Use Façade pattern when You want to provide a simple interface [...]

Aug
27
2010

Design Patterns : Adapter pattern

Adapter Pattern

Motivation Sometime a toolkit class that’s designed for reuse isn’t reusable only because its interface doesn’t match the domain-specific interface an application requires. Intent Convert the interface of a class into another interface client expects. Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. Diagram Applicability You want to use an existing class, and its interface does not match the one you need. You want to create a reusable class that cooperates [...]

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 [...]

Pages:123456»