Skip to Main Content
Learning JavaScript Design Patterns, 2nd Edition
book

Learning JavaScript Design Patterns, 2nd Edition

by Addy Osmani
April 2023
Intermediate to advanced content levelIntermediate to advanced
298 pages
6h 44m
English
O'Reilly Media, Inc.
Book available
Content preview from Learning JavaScript Design Patterns, 2nd Edition

Chapter 3. Structuring and Writing Patterns

The success of a new idea depends on its utility and also on how you present it to those it is trying to help. For developers to understand and adopt a design pattern, it should be presented with relevant information about the context, circumstances, prerequisites, and significant examples. This chapter applies to those trying to understand a specific pattern and those trying to introduce a new one because it provides essential information on how patterns are structured and written.

The Structure of a Design Pattern

Pattern authors would be unable to successfully create and publish a pattern if they cannot define its purpose. Similarly, developers will find understanding or implementing a pattern challenging if they do not have a background or context.

Pattern authors must outline a new pattern’s design, implementation, and purpose. Authors initially present a new pattern in the form of a rule that establishes a relationship between:

  • A context

  • A system of forces that arises in that context

  • A configuration that allows these forces to resolve themselves in context

With this in mind, let’s now summarize the component elements for a design pattern. A design pattern should have the following, with the first five elements being the most important:

Pattern name

A unique name representative of the purpose of the pattern.

Description

A brief description of what the pattern helps achieve.

Context outline

The contexts in which the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Modern JavaScript From The Beginning

Modern JavaScript From The Beginning

Brad Traversy
Node.js Design Patterns - Third Edition

Node.js Design Patterns - Third Edition

Mario Casciaro, Luciano Mammino

Publisher Resources

ISBN: 9781098139865Errata PageSupplemental Content