“SPA Design and Architecture: Understanding Single Page Web Applications” by Emmit Scott is a hands-on approach to developing single page web applications with examples covering three frameworks: Angular, Knockout and Backbone.
I came across this book through a recommendation from one of my colleagues. I worked as a frontend developer on a single page web application, but I wasn’t quite involved in the architectural decisions made, so I found it interesting in this book to read about what is the proper way, or, what should I look at, when thinking about how to build a single page web application. Also, the fact that there are examples for three frameworks/libraries for some of the concepts presented in the book was a definitely plus for me.
The book is easy to read because the author’s voice makes you feel like you’re watching over his shoulder while he’s explaining all this stuff to you. All the information is logically grouped and accompanied by many diagrams and sketches to better understand what’s being explained.
I liked chapter three, because it’s really important nowadays to correctly separate your code into modules in order to make it more maintainable and easier to add new features. The author starts with examples of why and when we need modules and how we might implement them. It discusses the module pattern and it’s variations as well as clojures and namespacing. The last topic in the chapter is about script loading and the author does a good job of explaining what AMD is and why we need it.
Chapter eight talks about unit testing. You should write unit tests. Always. Starting with SPAs, a lot of the business logic has shifted from backend to frontend and we need to make sure that everything works as expected. The chapter starts out by presenting the benefits of unit tests. It also introduces a small project and talks about what should be tested in that project, how to approach it. The author chooses QUnit for writing the unit tests of the sample project, which is a little disappointing as I would have liked to have some examples also for Jasmine.
Pros and cons
- A lot of diagrams and illustrations
- Examples covering three different frameworks: Angular, Backbone and Knockout
- Well structured
- Easy to read and understand
- React is not covered
- Unit tests only cover QUnit
- Caching is not discussed