Mastering JavaScript Design Patterns - Second Edition
By Simon Timms
5/5
()
About this ebook
- Learn how to use tried and true software design methodologies to enhance your JavaScript code
- Discover robust JavaScript implementations of classic and advanced design patterns
- Packed with easy-to-follow examples that can be used to create reusable code and extensible designs
This book is ideal for developers who want to gain expertise in object-oriented programming with JavaScript and the new capabilities of ES-2015 in order to improve their web development skills and build professional-quality web applications.
Simon Timms
Simon Timms is a developer who works in the oil and gas industry in Calgary, Alberta. He has a BSc in Computing Science from the University of Alberta and a Masters from Athabasca University. He is interested in distributed systems, visualization, and the acquisition of ice-cream. This is his first book, but he blogs frequently on diverse topics such as code contracts and cloud computing at blog.simontimms.com. He is involved in the local .NET and JavaScript community, and speaks frequently at conferences. Contacted by Shweta Pant on 28-8-2017 for the third edition of Mastering JavaScript Design Patterns book
Related to Mastering JavaScript Design Patterns - Second Edition
Related ebooks
Mastering JavaScript Design Patterns Rating: 4 out of 5 stars4/5Clean Code in JavaScript: Develop reliable, maintainable, and robust JavaScript Rating: 4 out of 5 stars4/5TypeScript Essentials Rating: 4 out of 5 stars4/5Learning JavaScript Data Structures and Algorithms - Second Edition Rating: 0 out of 5 stars0 ratingsLearning JavaScript Data Structures and Algorithms Rating: 5 out of 5 stars5/5TypeScript Design Patterns Rating: 0 out of 5 stars0 ratingsNode.js Design Patterns - Second Edition Rating: 4 out of 5 stars4/5React.js Essentials Rating: 4 out of 5 stars4/5Getting Started with React Rating: 0 out of 5 stars0 ratingsFront-end Development with ASP.NET Core, Angular, and Bootstrap Rating: 0 out of 5 stars0 ratingsLearn React Hooks: Build and refactor modern React.js applications using Hooks Rating: 0 out of 5 stars0 ratingsRust In Practice Rating: 0 out of 5 stars0 ratingsMastering JavaScript Object-Oriented Programming Rating: 0 out of 5 stars0 ratingsMastering Objectoriented Python Rating: 5 out of 5 stars5/5Learning Python Design Patterns - Second Edition: Learning Python Design Patterns - Second Edition Rating: 0 out of 5 stars0 ratingsLearn Rust Programming: Safe Code, Supports Low Level and Embedded Systems Programming with a Strong Ecosystem (English Edition) Rating: 0 out of 5 stars0 ratings.NET Design Patterns Rating: 3 out of 5 stars3/5JavaScript: Best Practice Rating: 4 out of 5 stars4/5Beginning C++ Programming Rating: 3 out of 5 stars3/5Object-Oriented JavaScript - Third Edition Rating: 4 out of 5 stars4/5Node.js By Example Rating: 2 out of 5 stars2/5ASP.NET Core for Jobseekers: Build Career in Designing Cross-Platform Web Applications Using Razor and Entity Framework Core Rating: 0 out of 5 stars0 ratingsASP.NET Core 3 and React: Hands-On full stack web development using ASP.NET Core, React, and TypeScript 3 Rating: 0 out of 5 stars0 ratingsJava Coding Problems: Improve your Java Programming skills by solving real-world coding challenges Rating: 0 out of 5 stars0 ratingsCase Studies in Design Patterns Rating: 5 out of 5 stars5/5Mastering Rust Programming: From Foundations to Future Rating: 0 out of 5 stars0 ratingsNode.js Design Patterns Rating: 4 out of 5 stars4/5
Software Development & Engineering For You
AI Money Methods: 7 Proven Ways to Use AI Tools to Make Money From Home in 2026 Rating: 0 out of 5 stars0 ratingsProduct Design: A Course in First Principles Rating: 0 out of 5 stars0 ratingsEvidence Guided: Creating High Impact Products in the Face of Uncertainty Rating: 5 out of 5 stars5/5Drawing in the Digital Age: An Observational Method for Artists and Animators Rating: 1 out of 5 stars1/5Software Testing: A Guide to Testing Mobile Apps, Websites, and Games Rating: 4 out of 5 stars4/5Consumption Economics: The New Rules of Tech Rating: 5 out of 5 stars5/5OCP Oracle Certified Professional Java SE 11 Programmer II Study Guide: Exam 1Z0-816 and Exam 1Z0-817 Rating: 5 out of 5 stars5/5Learn Clip Studio Paint: A beginner's guide to creating compelling art in manga, comics, and animation Rating: 0 out of 5 stars0 ratingsMastering Microsoft Endpoint Manager Rating: 0 out of 5 stars0 ratingsSelenium Framework Design in Keyword-Driven Testing: Automate Your Test Using Selenium and Appium Rating: 0 out of 5 stars0 ratingsLearning Django 5 Rating: 0 out of 5 stars0 ratingsThe Coder Habits: The #39# Habits of the Professional Programmer Rating: 5 out of 5 stars5/5Build GenAI Agents with OpenAI + vLLM Rating: 0 out of 5 stars0 ratingsAcing the Certified Kubernetes Administrator Exam Rating: 0 out of 5 stars0 ratings3D Printing Designs: Fun and Functional Projects Rating: 0 out of 5 stars0 ratingsThe Photographer's Guide to Luminar 4 Rating: 5 out of 5 stars5/5Stop Staring! 100 Graphic Design Projects to Break Your Creative Block Rating: 0 out of 5 stars0 ratingsMaking Money By Selling Photos, Vector Drawings, Videos, 3D Models Online Rating: 5 out of 5 stars5/5PRODUCT MASTERY A MASTERCLASS IN PRODUCT MANAGEMENT: Crafting Innovations, Navigating Challenges, Driving Success Rating: 0 out of 5 stars0 ratingsCode with Java 21: A practical approach for building robust and efficient applications (English Edition) Rating: 0 out of 5 stars0 ratingsSelenium with Python - A Beginner’s Guide: Get started with Selenium using Python as a programming language Rating: 0 out of 5 stars0 ratingsIterative Business Model Canvas Development - From Vision to Product Backlog: Agile Development of Products and Business Models Rating: 0 out of 5 stars0 ratingsRealizing 3D Animation in Blender: Master the fundamentals of 3D animation in Blender, from keyframing to character movement Rating: 0 out of 5 stars0 ratingsUser Experience Mapping Rating: 2 out of 5 stars2/5Mastering Augmented Reality Development with Unity: Create immersive and engaging AR experiences with Unity (English Edition) Rating: 0 out of 5 stars0 ratingsBuilding a Web App with Blazor and ASP .Net Core: Create a Single Page App with Blazor Server and Entity Framework Core Rating: 0 out of 5 stars0 ratingsJava Programming for Android Developers For Dummies Rating: 0 out of 5 stars0 ratings
Reviews for Mastering JavaScript Design Patterns - Second Edition
1 rating0 reviews
Book preview
Mastering JavaScript Design Patterns - Second Edition - Simon Timms
Chapter 1. Designing for Fun and Profit
JavaScript is an evolving language that has come a long way from its inception. Possibly more than any other programming language, it has grown and changed with the growth of the World Wide Web. The exploration of how JavaScript can be written using good design principles is the topic of this book. The preface of this book contains a detailed explanation of the sections of the book.
In the first half of this chapter, we'll explore the history of JavaScript and how it came to be the important language that it is today. As JavaScript has evolved and grown in importance, the need to apply rigorous methods to its construction has also grown. Design patterns can be a very useful tool to assist in developing maintainable code. The second half of the chapter will be dedicated to the theory of design patterns. Finally, we'll look briefly at anti-patterns.
The topics in this chapter are as follows:
History of JavaScript
What is a design pattern?
Anti-patterns
The road to JavaScript
We'll never know how language first came into being. Did it slowly evolve from a series of grunts and guttural sounds made during grooming rituals? Perhaps it developed to allow mothers and their offspring to communicate. Both of these are theories, all but impossible to prove. Nobody was around to observe our ancestors during that important period. In fact, the general lack of empirical evidence led the Linguistic Society of Paris to ban further discussions on the topic, seeing it as unsuitable for serious study.
The early days
Fortunately, programming languages have developed in recent history and we've been able to watch them grow and change. JavaScript has one of the more interesting histories of modern programming languages. During what must have been an absolutely frantic 10 days in May of 1995, a programmer at Netscape wrote the foundation for what would grow up to be modern JavaScript.
At the time, Netscape was involved in the first of the browser wars with Microsoft. The vision for Netscape was far grander than simply developing a browser. They wanted to create an entire distributed operating system making use of Sun Microsystems' recently-released Java programming language. Java was a much more modern alternative to the C++ Microsoft was pushing. However, Netscape didn't have an answer to Visual Basic. Visual Basic was an easier to use programming language, which was targeted at developers with less experience. It avoided some of the difficulties around memory management that make C and C++ notoriously difficult to program. Visual Basic also avoided strict typing and overall allowed more leeway. Here is an illustration of the timeline of JavaScript:
The early daysBrendan Eich was tasked with developing Netscape repartee to VB. The project was initially codenamed Mocha, but was renamed LiveScript before Netscape 2.0 beta was released. By the time the full release was available, Mocha/LiveScript had been renamed JavaScript to tie it into the Java applet integration. Java Applets were small applications which ran in the browser. They had a different security model from the browser itself and so were limited in how they could interact with both the browser and the local system. It is quite rare to see applets these days, as much of their functionality has become part of the browser. Java was riding a popular wave at the time and any relationship to it was played up.
The name has caused much confusion over the years. JavaScript is a very different language from Java. JavaScript is an interpreted language with loose typing, which runs primarily on the browser. Java is a language that is compiled to bytecode, which is then executed on the Java Virtual Machine. It has applicability in numerous scenarios, from the browser (through the use of Java applets), to the server (Tomcat, JBoss, and so on), to full desktop applications (Eclipse, OpenOffice, and so on). In most laypersons' minds, the confusion remains.
JavaScript turned out to be really quite useful for interacting with the web browser. It was not long until Microsoft had also adopted JavaScript into their Internet Explorer to complement VBScript. The Microsoft implementation was known as JScript.
By late 1996, it was clear that JavaScript was going to be the winning web language for the near future. In order to limit the amount of language deviation between implementations, Sun and Netscape began working with the European Computer Manufacturers Association (ECMA) to develop a standard to which future versions of JavaScript would need to comply. The standard was released very quickly (very quickly in terms of how rapidly standards organizations move), in July of 1997. On the off chance that you have not seen enough names yet for JavaScript, the standard version was called ECMAScript, a name which still persists in some circles.
Unfortunately, the standard only specified the very core parts of JavaScript. With the browser wars raging, it was apparent that any vendor that stuck with only the basic implementation of JavaScript would quickly be left behind. At the same time, there was much work going on to establish a standard Document Object Model (DOM) for browsers. The DOM was, in effect, an API for a web page that could be manipulated using JavaScript.
For many years, every JavaScript script would start by attempting to determine the browser on which it was running. This would dictate how to address elements in the DOM, as there were dramatic deviations between each browser. The spaghetti of code that was required to perform simple actions was legendary. I remember reading a year-long 20-part series on developing a Dynamic HTML (DHTML) drop down menu such that it would work on both Internet Explorer and Netscape Navigator. The same functionally can now be achieved with pure CSS without even having to resort to
