Skip to main content Accessibility help
×
Hostname: page-component-77c89778f8-9q27g Total loading time: 0 Render date: 2024-07-22T02:25:20.209Z Has data issue: false hasContentIssue false

10 - Design patterns

Published online by Cambridge University Press:  05 August 2012

Philip Levis
Affiliation:
Stanford University, California
David Gay
Affiliation:
Intel Research, Berkeley
Get access

Summary

To quote the Gang of Four, design patterns are “descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.” [3] In the components we've seen so far, we see several recurring patterns, such as the use of parameterized interfaces to implement services with multiple clients (VirtualizeTimerC, Section 9.1.3), or one component wrapping another (RandomC, Section 4.2). In this chapter, in the spirit of the Gang of Four's original design patterns work, we attempt to formalize a number of these patterns, based on our observations during TinyOS's development.

This chapter presents eight nesC design patterns: three behavioral (relating to component interaction): Dispatcher, Decorator, and Adapter, three structural (relating to how applications are structured): Service Instance, Placeholder, and Facade and two namespace (management of identifiers such as message types): Keyspace and Keymap. Each pattern's presentation follows the model of the Design Patterns book. Each one has an Intent, which briefly describes its purpose. A more in-depth Motivation follows, providing an example drawn from TinyOS. Applicable When provides a succinct list of conditions for use and a component diagram shows the Structure of how components in the pattern interact.1 In addition to our usual conventions for component diagrams, we attach folded sub-boxes to components to show relevant code snippets (a floating folded box represents source code in some other, unnamed, component). The diagram is followed by a Participants list explaining the role of each component. Sample Code shows an example nesC implementation, and Known Uses points to some uses of the pattern in TinyOS. Consequences describes how the pattern achieves its goals, and notes issues to consider when using it.

Type
Chapter
Information
TinyOS Programming , pp. 166 - 191
Publisher: Cambridge University Press
Print publication year: 2009

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Design patterns
  • Philip Levis, Stanford University, California, David Gay
  • Book: TinyOS Programming
  • Online publication: 05 August 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511626609.012
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Design patterns
  • Philip Levis, Stanford University, California, David Gay
  • Book: TinyOS Programming
  • Online publication: 05 August 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511626609.012
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Design patterns
  • Philip Levis, Stanford University, California, David Gay
  • Book: TinyOS Programming
  • Online publication: 05 August 2012
  • Chapter DOI: https://doi.org/10.1017/CBO9780511626609.012
Available formats
×