The soul of TinyOS Programming.



Dynamically select between a set of operations based on an identifier. Provides a way to easily extend or modify a system by adding or changing operations.

Applicable When

Acomponent needs to support an externally customisable set of operations.

Aprimitive integer type can identify which operation to perform.

The operations can all be implemented in terms of a single interface.


Enhance or modify a component’s capabilities without modifying its implementation. Be able to apply these changes to anycomponent that provides the interface.

Applicable When

You wish to extend the functionality of an existing component without changing its implementation, or

You wish to provide several variants of a component without having to implement each possible combination separately.


Convert the interface of a component into another interface, without modifying the original implementation. Allow two components with different interfaces to interoperate.

Applicable When

You wish to provide the functionality of an existing component with a different interface.


Service Instance

Allows multiple users to have separate instances of a particular service, where the instances can collaborate efficiently. The basic mechanism for virtualizing services.

Applicable When

A component needs to provide multiple instances of a service, but does not know how many until compile time.

Each service instance appears to its user to be independent of the others.

The service implementation needs to be able to easily access the state of every instance.


Easily change which implementation of a service an entire application uses. Prevent inadvertent inclusion of multiple, incompatible implementations.

Applicable When

Acomponent or service has multiple, mutually exclusive implementations.

Manysubsystems and parts of your application need to use this component/service.

You need to easily switch between the implementations.


Provides a unified access point to a set of inter-related services and interfaces. Simplifies use, inclusion, and composition of the subservices.

Applicable When

An abstraction, or series of related abstractions, is implemented across several separate components.

It is preferable to present the abstraction in whole rather than in parts.



Provide namespaces for referring to protocols, structures, or other entities in a program.

Applicable When

Aprogram mustkeep trackofa setof elements or data types.

The set is known and fixed at compile-time.


Mapkeys from onekeyset to another. Allows you to translate global, shared names to local, optimized names,ortoefficiently subset anotherkeyset.

Applicable When

An application uses global identifiers for communication (or other purposes) and wishes to map them to local identifiers for efficiency.

Two services are implemented following the Service Instance pattern, and the first service needs an instance of the second service for each of its own instances.

The identifiers are integer constants.

The map is known at compile-time.