Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Modular Programming with JavaScript
Modular Programming with JavaScript

Modular Programming with JavaScript: Modularize your JavaScript code for better readability, greater maintainability, and enhanced testability

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Modular Programming with JavaScript

Chapter 2. Review of Important JavaScript OOP Concepts

Before we start creating and using our modules in JavaScript, it is important to have a good grasp of important Object Oriented Programming (OOP) concepts in JavaScript. We will rely on such concepts to design and implement our application modules in later chapters.

While my intent in this chapter is not to explore such conceptes in great depth, I will try to provide a good overview of some of the most important related topics.

If you feel that you are quite familiar with these concepts in JavaScript, you could skip this chapter and move on to the next one.

However, if you are not very familiar with OOP in JavaScript, even if you are familiar with similar concepts in classical object oriented languages, I encourage you to follow along as things are a little different in JavaScript. I think it will be worthwhile for you to have a look at these concepts in the realm of JavaScript.

In this chapter, we will cover:

  • JavaScript objects...

JavaScript objects

If you have programmed in JavaScript before (as I'm sure you have, since this book is intended for intermediate to advanced JavaScript programmers), you will certainly have used objects, even if you have not been aware of their inner workings.

If you are familiar with other more classical object oriented languages (such as C++, C#, or Java), you'll be surprised to know that there is no formal syntax for defining classes in JavaScript (at least till ECMAScript 6). I think you'll be even more surprised to find out that, without having a formal syntax, you are still able to create classes in JavaScript and harness the full power of object oriented design and architecture (and one could even argue in a more flexible way).

Note

Formal class definition in JavaScript

In the newer version of JavaScript (ES6), new syntax allows you to define classes in a more formal and structured way.

For more information visit the following link:

http://es6-features.org/

You can...

Summary

The goal of this chapter was to provide a quick overview of some OOP concepts in JavaScript. Having a good understanding of these concepts is important as we will be using them in implementing our modular architecture in the following chapters.

In this chapter, we looked at various ways of creating objects as well as concepts such as closure, encapsulation, and inheritance.

The assumption that I made was that you likely have a fairly good experience with JavaScript and are probably familiar with at least some of these concepts.

My intent was to provide "just enough" of a review of JavaScript OOP concepts to get you ready for future chapters.

There are many good resources available that can help you extend your knowledge of Object Oriented JavaScript principles further.

Two of my personal favorites on this topic are:

  • Object-Oriented JavaScript, Stoyan Stefanov, Kumar Chetan Sharma
  • Professional JavaScript for Web Developers, Nicholas C. Zakas

In the next chapter, we will start focusing...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Design and build fully modular, modern JavaScript applications using modular design concepts
  • Improve code portability, maintainability, and integrity while creating highly scalable and responsive web applications
  • Implement your own loosely coupled code blocks that can power highly maintainable and powerful applications in a flexible and highly responsive modular architecture

Description

Programming in the modular manner is always encouraged for bigger systems—it is easier to achieve scalability with modular programming. Even JavaScript developers are now interested in building programs in a modular pattern. Modules help people who aren’t yet familiar with code to find what they are looking for and also makes it easier for programmers to keep things that are related close together. Designing and implementing applications in a modular manner is highly encouraged and desirable in both simple and enterprise level applications. This book covers some real-life examples of modules and how we can translate that into our world of programming and application design. After getting an overview of JavaScript object-oriented programming (OOP) concepts and their practical usage, you should be able to write your own object definitions using the module pattern. You will then learn to design and augment modules and will explore the concepts of cloning, inheritance, sub-modules, and code extensibility. You will also learn about SandBoxing, application design, and architecture based on modular design concepts. Become familiar with AMD and CommonJS utilities. By the end of the book, you will be able to build spectacular modular applications in JavaScript.

Who is this book for?

If you are an intermediate to advanced JavaScript developer who has experience of writing JavaScript code but probably not in a modular, portable manner, or you are looking to develop enterprise level JavaScript applications, then this book is for you. A basic understanding of JavaScript concepts such as OOP, prototypal inheritance, and closures is expected.

What you will learn

  • Understand the important concepts of OOP in JavaScript, such as scope, objects, inheritance, event delegation, and more
  • Find out how the module design pattern is used in OOP in JavaScript
  • Design and augment modules using both tight augmentation and loose augmentation
  • Extend the capabilities of modules by creating sub-modules using techniques such as cloning and inheritance
  • Move from isolated module pieces to a cohesive, well integrated application modules that can interact and work together without being tightly coupled
  • See how SandBoxing is used to create a medium for all the modules to talk to each other as well as to the core
  • Use the concepts of modular application design to handle dependencies and load modules asynchronously
  • Become familiar with AMD and CommonJS utilities and discover what the future of JavaScript holds for modular programming and architecture

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 28, 2016
Length: 274 pages
Edition : 1st
Language : English
ISBN-13 : 9781785883996
Category :
Languages :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jul 28, 2016
Length: 274 pages
Edition : 1st
Language : English
ISBN-13 : 9781785883996
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 115.97
Mastering JavaScript Object-Oriented Programming
€36.99
Modular Programming with JavaScript
€36.99
Modern JavaScript Applications
€41.99
Total 115.97 Stars icon
Banner background image

Table of Contents

11 Chapters
1. What Are Modules and Their Advantages? Chevron down icon Chevron up icon
2. Review of Important JavaScript OOP Concepts Chevron down icon Chevron up icon
3. Module Design Pattern Chevron down icon Chevron up icon
4. Designing Simple Modules Chevron down icon Chevron up icon
5. Module Augmentation Chevron down icon Chevron up icon
6. Cloning, Inheritance, and Submodules Chevron down icon Chevron up icon
7. Base, Sandbox, and Core Modules Chevron down icon Chevron up icon
8. Application Implementation – Putting It All Together Chevron down icon Chevron up icon
9. Modular Application Design and Testing Chevron down icon Chevron up icon
10. Enterprise Grade Modular Design, AMD, CommonJS, and ES6 Modules Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.5
(2 Ratings)
5 star 0%
4 star 50%
3 star 50%
2 star 0%
1 star 0%
Konstantin Jun 06, 2017
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
this is a fantastic book that teachers you how to build modular applications in javascript... and i am very happy i stumbled on it. It takes a very systematic approach towards the topic (building javascript applications using MVC/MV* patterns). I think the author has done a great job! There are some typos in the book though(that pretty much applications to all books)... that said, i cant recommend it enough! get it :-)
Amazon Verified review Amazon
RC Mar 26, 2018
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Had this book been published at the same time the ES5 standard was released (2009), I would give it 5 stars. The author does an excellent job at explaining how to create modules using IIFE (Immediately Invoked Function Expression), module augmentation techniques, OOP concepts, structural & behavior design patterns ( Facade, Mediator, Pub/Sub) and implements an excellent modular SPA (Single Page App) architecture based on Nicholas Zakas's 'Scalable JavaScript Application Architecture.'Because it was published after the release of the ES6/ES2015 standard, most of the content is dated. Since the release of ES2015 modules and modern browsers now supporting ES6 Modules, IIFE's are no longer the preferred technique to create modularity. The author dedicates only 4 pages to ES2015 modules.This book should have been about:1. How to migrate legacy IIFE modules to ES6 Modules2. How to use transpilers like Babel to create modules in ES6 and transpile back to ES5 module APIs (AMD, CommonJS, etc.).3. How to use tools like Webpack to support non-ES6 legacy browsers.4. Implementing the latest techniques for ES6 modules.In conclusion, the majority of the content is dated, however, one can still learn a lot on creating modularity with IIFE's and SPA modular architecture.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.