Mastering JavaScript Design Patterns
eBook - ePub

Mastering JavaScript Design Patterns

Simon Timms

Partager le livre
  1. 290 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Mastering JavaScript Design Patterns

Simon Timms

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

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.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Mastering JavaScript Design Patterns est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Mastering JavaScript Design Patterns par Simon Timms en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatica et Programmazione web. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2014
ISBN
9781783987986
Édition
1

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...

Table des matiĂšres