Book Image

Learning JavaScriptMVC

By : Wojciech Bednarski
Book Image

Learning JavaScriptMVC

By: Wojciech Bednarski

Overview of this book

<p>JavaScriptMVC is a client-side, JavaScript framework that builds maintainable, error-free, lightweight applications as quickly as possible. As it does not depend on server components, it can be combined with any web service interface and server-side language.<br /><br />"Learning JavaScriptMVC" will guide you through all the framework aspects and show you how to build small- to mid-size well-structured and documented client-side applications you will love to work on.<br /><br />This book starts from JavaScriptMVC installation and all its components are explained with practical examples. It finishes with an example of building a web application. You will learn what the JavaScriptMVC framework is, how to install it, and how to use it efficiently.<br /><br />This book will guide you on how to build a sample application from scratch, test its codebase using unit testing, as well as test the whole application using functional testing, document it, and deploy the same. After reading Learning JavaScriptMVC you will learn how to install the framework and create a well-structured, documented and maintainable client-side application.</p>
Table of Contents (13 chapters)

System architecture approach


When building web applications, we can distinguish between two approaches—multi-page application and single-page application.

In multi-page application, most of the business logic is implemented in the backend system, with some enhancement done in JavaScript. For example, the Ruby on Rails application, where most of the main logic is done by the backend MVC architecture and when a user navigates to another page, an ordinary http request is sent.

In single-page application, most of the business logic is implemented on the frontend side. For example, the JavaScriptMVC application, where most of the main logic is done by frontend MVC architecture. When a user navigates to another page, the frontend router dispatches all requests and makes calls to the back end API written; for example, in Sinatra.

JavaScriptMVC single-page application

JavaScriptMVC is designed for single-page application use cases. It's good to know about the advantages and disadvantages of the single-page application approach compared to that of the multi-page application.

Advantages

  • Most of the states are maintained in the client, so we don't need to keep the session states on the server side

  • Most of the requests are done through XRH calls, so there is no need to load a new page each time, which could cause high memory footprint (especially in the old fashion, non event-based servers such as Apache)

  • Most of the business logic is on the client side, so we can save many calls to the server

Downsides

  • Load balance and Content Delivery Network (CDN) can be tricky since RPC is used to move data back and forth between the server and client.

  • Search Engine Optimization (SEO) can be tricky due to on-demand JavaScript built pages.