Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
MASTERING KNOCKOUTJS

You're reading from   MASTERING KNOCKOUTJS Use and extend Knockout to deliver feature-rich, modern web applications

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781783981007
Length 270 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Timothy Moran Timothy Moran
Author Profile Icon Timothy Moran
Timothy Moran
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Knockout Essentials 2. Extending Knockout with Custom Binding Handlers FREE CHAPTER 3. Extending Knockout with Preprocessors and Providers 4. Application Development with Components and Modules 5. Durandal – the Knockout Framework 6. Advanced Durandal 7. Best Practices 8. Plugins and Other Knockout Libraries 9. Under the Hood Index

Creating small modules


Creating smaller modules makes unit testing simpler and reduces the effort required to understand the code for others who have to read it. When deciding whether or not to add functionalities to a module or split it off into a new one, keep the single responsibility principle in mind.

This is a bit of a balancing act. If you have a RESTful API for your JavaScript application, then creating modules to abstract away the individual URLs by providing methods for them is a good idea. Having a single dataService module that contains all of the URLs for the whole application, though, will result in a very large module in even medium-sized applications. On the other hand, having a service module for each individual route will produce an even larger number of files. This will make unit testing and maintenance harder, it won't make it easier. The best course is to group the routes into modules by functionality. In the case of REST URLs, grouping them by resource produces a very...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime