5星 · 超过95%的资源 需积分: 35 153 浏览量 更新于2023-05-27 评论 4 收藏 26.2MB PDF 举报
A book by Addy Osmani
Copyright © Addy Osmani 2015.
Noncommercial-No Derivative Works 3.0 unported license. It is available for purchase
via O'Reilly Media but will remain available for both free online and as a physical (or
eBook) purchase for readers wishing to support the project.
Design patterns are reusable solutions to commonly occurring problems in software
design. They are both exciting and a fascinating topic to explore in any programming
One reason for this is that they help us build upon the combined experience of many
developers that came before us and ensure we structure our code in an optimized way,
meeting the needs of problems we're attempting to solve.
Design patterns also provide us a common vocabulary to describe solutions. This can be
signiﬁcantly simpler than describing syntax and semantics when we're attempting to
convey a way of structuring a solution in code form to others.
In this book we will explore applying both classical and modern design patterns to the
This book is targeted at professional developers wishing to improve their knowledge of
Some of the concepts covered (closures, prototypal inheritance) will assume a level of
basic prior knowledge and understanding. If you ﬁnd yourself needing to read further
about these topics, a list of suggested titles is provided for convenience.
If you would like to learn how to write beautiful, structured and organized code, I
believe this is the book for you.
I will always be grateful for the talented technical reviewers who helped review and
improve this book, including those from the community at large. The knowledge and
enthusiasm they brought to the project was simply amazing. The ofﬁcial technical
reviewers tweets and blogs are also a regular source of both ideas and inspiration and I
wholeheartedly recommend checking them out.
Nicholas Zakas (http://nczonline.net, @slicknet)
Andrée Hansson (http://andreehansson.se, @peolanha)
Luke Smith (http://lucassmith.name, @ls_n)
Eric Ferraiuolo (http://ericf.me/, @ericf)
Peter Michaux (http://michaux.ca, @petermichaux)
Alex Sexton (http://alexsexton.com, @slexaxton)
I would also like to thank Rebecca Murphey (http://rmurphey.com, @rmurphey) for
providing the inspiration to write this book and more importantly, continue to make it
both available on GitHub and via O'Reilly.
Finally, I would like to thank my wonderful wife Ellie, for all of her support while I was
putting together this publication.
Whilst some of the patterns covered in this book were implemented based on personal
This work is as such the production of the combined experience of a number of
developers. Similar to Stoyan Stefanov's logical approach to preventing interruption of
reading for any content covered in the references section.
If any articles or links have been missed in the list of references, please accept my
heartfelt apologies. If you contact me I'll be sure to update them to include you on the
Whilst this book is targeted at both beginners and intermediate developers, a basic
about the language, I am happy to recommend the following titles:
Table Of Contents
What is a Pattern?
"Pattern"-ity Testing, Proto-Patterns & The Rule Of Three
The Structure Of A Design Pattern
Writing Design Patterns
Categories Of Design Pattern
Summary Table Of Design Pattern Categorization
Revealing Module Pattern
Design Patterns In jQuery
Lazy Initialization Pattern
jQuery Plugin Design Patterns
One of the most important aspects of writing maintainable code is being able to notice
the recurring themes in that code and optimize them. This is an area where knowledge
of design patterns can prove invaluable.
In the ﬁrst part of this book, we will explore the history and importance of design
patterns which can really be applied to any programming language. If you're already
sold on or are familiar with this history, feel free to skip to the chapter "What is a
Pattern?" to continue reading.
Design patterns can be traced back to the early work of an architect named Christopher
Alexander. He would often write publications about his experience in solving design
issues and how they related to buildings and towns. One day, it occurred to Alexander
that when used time and time again, certain design constructs lead to a desired optimal
In collaboration with Sara Ishikawa and Murray Silverstein, Alexander produced a
pattern language that would help empower anyone wishing to design and build at any
scale. This was published back in 1977 in a paper titled "A Pattern Language", which
was later released as a complete hardcover book.
Some 30 years ago, software engineers began to incorporate the principles Alexander
had written about into the ﬁrst documentation about design patterns, which was to be a
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额