Mastering JavaScript Design Patterns
eBook - ePub

Mastering JavaScript Design Patterns

Simon Timms

Buch teilen
  1. 290 Seiten
  2. English
  3. ePUB (handyfreundlich)
  4. Über iOS und Android verfügbar
eBook - ePub

Mastering JavaScript Design Patterns

Simon Timms

Angaben zum Buch
Buchvorschau
Inhaltsverzeichnis
Quellenangaben

Über dieses Buch

Applying design patterns to JavaScript code creates more reliable and maintainable code. In this book, you will explore different design patterns and learn where and how to implement them with the help of detailed examples.

In the first part of the book, we start off with an introduction to design patterns, and then move on to creating classical structures that are used to organize code. Next, we look at the creational, structural, and behavioral patterns. The second part of the book dives into patterns used for functional programming, model view patterns, patterns to build web applications, and messaging patterns. A number of very interesting advanced JavaScript patterns such as dependency injection and live postprocessing are also covered.

By the end of this book, you will learn to identify places where a pattern would improve code readability and maintainability.

Häufig gestellte Fragen

Wie kann ich mein Abo kündigen?
Gehe einfach zum Kontobereich in den Einstellungen und klicke auf „Abo kündigen“ – ganz einfach. Nachdem du gekündigt hast, bleibt deine Mitgliedschaft für den verbleibenden Abozeitraum, den du bereits bezahlt hast, aktiv. Mehr Informationen hier.
(Wie) Kann ich Bücher herunterladen?
Derzeit stehen all unsere auf Mobilgeräte reagierenden ePub-Bücher zum Download über die App zur Verfügung. Die meisten unserer PDFs stehen ebenfalls zum Download bereit; wir arbeiten daran, auch die übrigen PDFs zum Download anzubieten, bei denen dies aktuell noch nicht möglich ist. Weitere Informationen hier.
Welcher Unterschied besteht bei den Preisen zwischen den Aboplänen?
Mit beiden Aboplänen erhältst du vollen Zugang zur Bibliothek und allen Funktionen von Perlego. Die einzigen Unterschiede bestehen im Preis und dem Abozeitraum: Mit dem Jahresabo sparst du auf 12 Monate gerechnet im Vergleich zum Monatsabo rund 30 %.
Was ist Perlego?
Wir sind ein Online-Abodienst für Lehrbücher, bei dem du für weniger als den Preis eines einzelnen Buches pro Monat Zugang zu einer ganzen Online-Bibliothek erhältst. Mit über 1 Million Büchern zu über 1.000 verschiedenen Themen haben wir bestimmt alles, was du brauchst! Weitere Informationen hier.
Unterstützt Perlego Text-zu-Sprache?
Achte auf das Symbol zum Vorlesen in deinem nächsten Buch, um zu sehen, ob du es dir auch anhören kannst. Bei diesem Tool wird dir Text laut vorgelesen, wobei der Text beim Vorlesen auch grafisch hervorgehoben wird. Du kannst das Vorlesen jederzeit anhalten, beschleunigen und verlangsamen. Weitere Informationen hier.
Ist Mastering JavaScript Design Patterns als Online-PDF/ePub verfügbar?
Ja, du hast Zugang zu Mastering JavaScript Design Patterns von Simon Timms im PDF- und/oder ePub-Format sowie zu anderen beliebten Büchern aus Informatica & Programmazione web. Aus unserem Katalog stehen dir über 1 Million Bücher zur Verfügung.

Information

Jahr
2014
ISBN
9781783987986

Mastering JavaScript Design Patterns


Table of Contents

Mastering JavaScript Design Patterns
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Designing for Fun and Profit
The road to JavaScript
The early days
A pause
The way of Gmail
JavaScript everywhere
What is a design pattern?
Antipatterns
Summary
I. Classical Design Patterns
2. Organizing Code
Chunks of code
What's the matter with global scope anyway?
Objects in JavaScript
Build me a prototype
Inheritance
Modules
ECMAScript 6 classes and modules
Best practices and troubleshooting
Summary
3. Creational Patterns
Abstract Factory
Implementation
Builder
Implementation
Factory Method
Implementation
Singleton
Implementation
Disadvantages
Prototype
Implementation
Hints and tips
Summary
4. Structural Patterns
Adapter
Implementation
Bridge
Implementation
Composite
An example
Implementation
Decorator
Implementation
Façade
Implementation
Flyweight
Implementation
Proxy
Implementation
Hints and tips
Summary
5. Behavioral Patterns
Chain of responsibility
Implementation
Command
The command message
The invoker
The receiver
Interpreter
An example
Implementation
Iterator
Implementation
ECMAScript 6 iterators
Mediator
Implementation
Memento
Implementation
Observer
Implementation
State
Implementation
Strategy
Implementation
Template method
Implementation
Visitor
Hints and tips
Summary
II. Other Patterns
6. Functional Programming
Functional functions are side-effect free
Function passing
Implementation
Filters and pipes
Implementation
Accumulators
Implementation
Memoization
Implementation
Immutability
Lazy instantiation
Implementation
Hints and tips
Summary
7. Model View Patterns
First, some history
Model View Controller
The MVC code
Model View Presenter
The MVP code
Model View ViewModel
The MVVM code
A better way to transfer changes between the model and the view
Observing view changes
Hints and tips
Summary
8. Web Patterns
Sending JavaScript
Combining files
Minification
Content delivery networks
Plugins
jQuery
d3
Doing two things at once – multithreading
The circuit breaker pattern
Back-off
Degraded application behavior
The promise pattern
Hints and tips
Summary
9. Messaging Patterns
What's a message anyway?
Commands
Events
Request-reply
Publish-subscribe
Fan out and fan in
Dead-letter queues
Message replay
Pipes and filters
Versioning messages
Hints and tips
Summary
10. Patterns for Testing
The testing pyramid
Test in the small with unit tests
Arrange-Act-Assert
Asserts
Fake objects
Test spies
Stub
Mock
Monkey patching
Interacting with the user interface
Browser testing
Faking the DOM
Wrapping the manipulation
Build and test tools
Hints and tips
Summary
11. Advanced Patterns
Dependency injection
Live postprocessing
Aspect-oriented programming
Macros
Hints and tips
Summary
12. ES6 Solutions Today
TypeScript
The class syntax
The module syntax
Arrow functions
Typing
Traceur
Classes
Default parameters
Template literals
Block bindings with let
Async
Conclusion
Hints and tips
Summary
A. Conclusion
Index

Mastering JavaScript Design Patterns

Copyright © 2014 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: November 2014
Production reference: 1151114
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78398-798-6
www.packtpub.com

Credits

Author
Simon Timms
Reviewers
Amrita Chaturvedi
Philippe Renevier Gonin
Pedro Miguel Barros Morgado
Mani Nilchiani
Commissioning Editor
Kunal Parikh
Acquisition Editor
Meeta Rajani
Content Development Editor
Sweny M. Sukumaran
Technical Editor
Siddhi Rane
Copy Editor
Laxmi Subramanian
Project Coordinator
Rashi Khivansara
Proofreaders
Simran Bhogal
Lawrence A. Herman
Elinor Perry-Smith
Indexer
Hemangini Bari
Graphics
Sheetal Aute
Ronak Dhruv
Valentina D'silva
Disha Haria
Abhinash Sahu
Production Coordinator
Nitesh Thakur
Cover Work
Nitesh Thakur

About the Author

Simon Timms is a developer who loves to write code. He writes in a variety of languages using a number of tools. For the most part, he develops web applications with .NET backends. He is very interested in visualizations and cloud computing. A background in build and system administration keeps him on the straight and narrow when it comes to DevOps.
He is the author of Social Data Visualization with HTML5 and JavaScript, Packt Publishing. He blogs at http://blog.simontimms.com/ and is also a frequent contributor to the Canadian Developer Connection, where his latest series explores evolving ASP.NET applications.
He is the President of the Calgary .NET User Group and a member of half a dozen others. He speaks on a variety of topics from DevOps to how the telephone system works.
He works as a web developer for Pacesetter Directional Drilling, the friendliest performance drilling company around.

About the Reviewers

Amrita Chaturvedi is a PhD researcher in the Department of Computer Science and Engineering at Indian Institute of Technology, Kanpur, Uttar Pradesh, India (http://www.cse.iitk.ac.in/users/amrita/index.htm). She was schooled (kindergarten to intermediate) at City Montessori School, Aliganj, Lucknow, Uttar Pradesh, India. She received a Bachelor of Technology degree in Information Technology from Institute of Engineering and Technology, Lucknow, Uttar Pradesh, India and a Master of Technology degree in Information Technology (with a specialization in Software Engineering) from Indian Institute of Information Technology, Allahabad (Deemed University), Uttar Pradesh, India. She has worked in Nucleus Software Exports Ltd., Noida, Uttar Pradesh, India as a software engineer. She was also employed as a faculty in Institute of Engineering and Technology, Lucknow, Uttar Pradesh, India. She has worked in user interface design as a senior project associate at Indian Institute of Technology, Kanpur, Uttar Pradesh, India. She was selected as the first female PhD student from Asia under EURECA (European Research and Educational Collaboration with Asia) project 2009 to conduct research at VU University Amsterdam, the Netherlands. Her areas of specialization are software engineering, software architecture, software design patterns, and ontologies. Her research interests include software architecture and design, ontologies-based software engineering, service-oriented and model-driven architecture, semantic web, Internet technologies, and mobile agents.
She has given several talks and seminars as well as conference welcome/key notes at international conferences. She has also earned various awards such as best paper award for her research paper in an international conference, ACM SIGAPP award, and has also been a Physics Olympiad topper. She has traveled several European, North American, African, and Asian countries for educational/conference/research purposes. She has teaching as well as research exper...

Inhaltsverzeichnis