Browse Prior Art Database

Design Pattern - Conditional Pattern (aka MultiKeyLock Pattern)

IP.com Disclosure Number: IPCOM000170685D
Original Publication Date: 2008-May-27
Included in the Prior Art Database: 2008-May-27
Document File: 5 page(s) / 112K

Publishing Venue

IBM

Abstract

Design of any reasonably complex software system involves determining its various components and how they interact. It implies that some components uses the services of (depends on) other components. Such a dependency relationship is inherent to the very nature of the design of systems. Although completely unavoidable, the degree of dependency could be minimized (loosely coupled), enabling the creation of easily replaceable components. Sometimes, by virtue of (lack of) design, the extent of dependency could be greater than the purpose of the relationship itself. One possible solution could be to use the event notification mechanism, whenever the status of an object changes. But, it does not solve the problem completely. This is because, to listen to events, it is required to subscribe to such an event, using an API of the object in question, which again implies a compile-time dependency. And, also gets tied to only one kind of object.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 34% of the total text.

Page 1 of 5

Design Pattern - Conditional Pattern (aka MultiKeyLock Pattern)

Name : Kiran N Mallekoppa

CONDITIONAL PATTERN (Object Behavioral )

Intent

Provide a mechanism to allow two or more (related) components to interact with each other in a loosely coupled manner without having to depend on each other.

Also Known As Multi-Key Lock, AND Gate

Motivation / Explanation

Design of any reasonably complex software system involves determining its various components and how they interact. It implies that some components uses the services of (depends on) other components. Such a dependency relationship is inherent to the very nature of the design of systems. Although completely unavoidable, the degree of dependency could be minimized (loosely coupled), enabling the creation of easily replaceable components. Sometimes, by virtue of (lack of) design, the extent of dependency could be greater than the purpose of the relationship itself.

Further, the system does have to interact with external world - the user, other software programs, remote computers over the network, variety of devices etc. These interactions are asynchronous - the occurrence of such events cannot be predicted. The occurrence of such events requires triggering a handling procedure as a response. The Conditional pattern facilitates to recognize the occurrence of such events without requiring the participating components to know each other.

The Conditional pattern allows more than one components to register themselves as participants with the Conditional object. Each of these participants implements a condition and an action function. Also, the Conditional object provides a method to evaluate the condition. Invoking this method would result in the invocation of the condition function of all the participants. Only when all the condition functions evaluate to TRUE, the overall condition(set of all conditions it represents) represented by the Conditional Object is also deemed to be TRUE; Otherwise, it evaluates to FALSE. The action functions of all the participants are then invoked with the result of the evaluation. The evaluation can be triggered by any of the participants, when required (say, when its state changes). Also, whenever a new participant is added or an existing participant removes itself the overall condition could be re-evaluated. Further, the number of participants can be limited.

It is similar to a lock that requires multiple keys to open it. It opens only when ALL the right keys are available. Therefore, this pattern also referred to as the Multi-Key Lock.

Also, it resembles the logical AND condition (AND Gate), where in the overall condition evaluates to TRUE only when all its participant's conditions evaluate to TRUE. Similarly, the condition represented by the Conditional Object evaluates to TRUE only when all the participant's condition functions ev...