Skip to Content
Learning JavaScript Design Patterns
book

Learning JavaScript Design Patterns

by Addy Osmani
July 2012
Intermediate to advanced content levelIntermediate to advanced
254 pages
6h 16m
English
O'Reilly Media, Inc.
Content preview from Learning JavaScript Design Patterns

Pros and Cons

We now hopefully have a better appreciation for what MVVM is and how it works. Let’s now review the advantages and disadvantages of employing the pattern.

Advantages

  • MVVM facilitates easier parallel development of a UI and the building blocks that power it.

  • MVVM abstracts the View and thus reduces the quantity of business logic (or glue) required in the code behind it.

  • The ViewModel can be easier to unit test than in the case of event-driven code.

  • The ViewModel (being more Model than View) can be tested without concerns of UI automation and interaction.

Disadvantages

  • For simpler UIs, MVVM can be overkill.

  • While data bindings can be declarative and nice to work with, they can be harder to debug than imperative code where we simply set breakpoints.

  • Data bindings in nontrivial applications can create a lot of bookkeeping. We also don’t want to end up in a situation where bindings are heavier than the objects being bound to.

  • In larger applications, it can be more difficult to design the ViewModel up front to get the necessary amount of generalization.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Design Patterns - Second Edition

Mastering JavaScript Design Patterns - Second Edition

Simon Timms
JavaScript Patterns

JavaScript Patterns

Stoyan Stefanov

Publisher Resources

ISBN: 9781449334840Errata Page