Book Image

SproutCore Web Application Development

By : Tyler Keating
Book Image

SproutCore Web Application Development

By: Tyler Keating

Overview of this book

SproutCore is a framework that exists to allow developers to deliver on the promise of the Web with more than just simple attractive demos, but with complex software and remarkable user experiences. SproutCore’s creators recognized early on that developing real web software requires the same software development tools and practices that have evolved over decades in the native software field and thus SproutCore brings these to the Web. SproutCore Web Application Development is more than just a guide to one of the largest and most powerful web application frameworks out there, it’s also a guide to writing genre defining web applications and solving the unique problems that the web platform creates. Containing the results of thousands of hours of software development experience, this book is invaluable for anyone already writing software for the Web or just starting out. SproutCore Web Application Development comprises of three sections. In the first section we introduce SproutCore and walk through a simple SproutCore application. From there, we look in detail at all of the main components of the framework before finally working through a rigorous real-world example from start to finish. Learning about SproutCore means learning about writing software for the Web. In this book, you will not only learn what sets SproutCore apart from other web libraries and frameworks, you will also learn about solving the difficult challenges that web development poses. We will look at all the components of an application and how to translate wireframes, mocks, and design descriptions into clean, efficient, and maintainable code using MVC, data adaptors, statecharts, and more. We will look at SproutCore’s powerful binding and observing and watch how changes propagate across our app effortlessly and magically with very little code. By the time you complete SproutCore Web Application Development, you’ll be ready to develop your own application that redefines what it means to be a web application.
Table of Contents (13 chapters)
SproutCore Web Application Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Unit testing SproutCore apps


I might as well admit it; I am a big fan of unit tests. Once I discovered that unit testing is really a code development tool for improving quality, I've been pretty much sold on them. But first let me explain why I believe unit tests are the best tool for improving the quality of code. Take this simple helper method of a view for example:

// Returns the display name of the content
displayName: function (content) {
  if (MyApp.isDownloading  && !this.isReady) {
    return "Downloading…";
  } else {
    return "Name: " + content.name;
  }
}

As short as this function is, it still manages to contain a couple of problems that would be highlighted by adding a unit test.

For an instance, it wouldn't take much time to spot problems when writing a unit test that asked "what happens if content is null?" and "what if content.name is undefined?". It also wouldn't take long while trying to test this method to discover that the dependency on external variables, MyApp...