Preface
Building Web Apps with Ember.js
Welcome to Building Web Apps with Ember.js! This book is largely about building production-capable, browser-based appplicatons. Some might call these single-page apps while others say HTML5 apps, client MVC apps, or rich Internet apps; but in the end, these types of applications are one and the same: the web browser is the application platform, and the server provides remote service endpoints. After years of writing and using many of the solutions available to manage complex applications of this type, we have settled on Ember.js as our primary toolset. In this book, we will attempt to both teach you what we know about Ember, and, along the way, demonstrate for you why it has become our primary toolset for building web applications.
In 2005, I (Jesse) discovered JavaScript and the XMLHttpRequest
object while working at a digital agency that deployed .NET and Drupal applications with rich, Flash and web frontends. At the time, JavaScript was a disrespected âtoyâ language used to sprinkle functionality onto the top of traditional web applications. Ironically, much of the JavaScript work I did then involved using flashvars to create a bridge between PHP and browser-based Flash applications.
But, at the time, Flash frontends were a necessary evil. Browsers were largely incapable of supporting rich, interactive experiences, and respectable JavaScript libraries like MooTools, YUI, and Dojo were only beginning to mature.
As I began taking additional risks by using more and more JavaScript in my applications, I started to find other like-minded developers that also believed that browsers would evolve and that JavaScript was more than just a toy language. We believed JavaScript was a full-featured, object-oriented, professional language that was capable of being used to build high-performing production applications. A strong community began to evolve, fueled largely by pioneers like Douglass Crockford, John Resig, Paul Irish, and Christian Heilmann to name a few, and eventually frontend developer became a professional job class in many organizations.
In 2007, I took my JavaScript skills to the enterprise. I was hired to begin building a complex, rich Internet application within an enterprise J2EE stack. This introduced me to many of the most common challenges presented by large-scale development: lack of JavaScript and frontend expertise, server-centric web legacy, complex cross-browser and mobile-web fragmentation compatibility requirements, and lack of provisioned desktop and development tooling for frontend developers, just to name a few. Being faced with all these limitations was some of the most challenging work of my careerânot to mention overcoming the naysayers that didnât want to see the end of safe, traditional web applications.
Over the next couple of years, I focused solely on implementing and deploying a solution that was in many ways before its time. Many of the tools that are available today were nascent, or nonexistent at the time, including client MV* libraries, client-side routing and object relational mappers (ORMs), JavaScript templates, JavaScript promises, async flow control libraries, and web components. Nevertheless, my team and I dreamed up and implemented custom solutions within the parameters of the project timelines and requirements. Overall it was a success, and our client MVC framework still remains in production today.
Since 2009, I have worked on numerous applications using Backbone, Angular, and Ember. But today, I often recommend Ember.js to the clients I work with. This is primarily due to the fact that the conventions support well-known web application development patterns that I have custom written or pieced together from multiple open source libraries. Here, are the high level concepts that, in my opinion, make Ember so valuable:
-
Emberâs object model supports a classic and well understood, object-oriented pattern of class inheritance through extend, object initialization, getters and setters, and class monkey patching.
-
Ember models, controllers, and components extend the
Object
class, which ensures that these objects inherit Emberâs powerful default data binding. -
The router supports complex nesting for URL-driven applications that manage application state in a conventional way that can be understood by those with web-server-routing backgrounds.
-
Recently, build, workflow, and testing tools in Ember have matured and become intuitive.
-
Emberâs only dependencies are on jQuery and Handlebars.js, two very well-known and documented libraries.
-
Finally, the community is vibrant, passionate, and extremely active.
In late 2012 and 2013, Thomas Brady and I found ourselves working on numerous ambitious web UIs in our work at frog design. Despite the nascency of the framework at the time, we felt Ember was the right tool for the job. We believed in the direction the framework was heading and in the community of talented developers behind it. At times it was frustrating, but in the end, I find myself saying all the time, âCan you imagine what it would take to do this in another framework?â
More Than Just âGetting Startedâ
If you are picking up this book, we assume you have interest in building full-stack, single-page applications. In other words, we assume that you would not only like to architect and build a fully functional, browser-based application, but also connect it to a backend. That being said, this book covers all aspects of building applications with Ember. So, in addition to providing you with a complete overview of the HTML and JavaScript necessary to write on the frontend, we also include an implicit project timeline via the structure and order of the chapters, development workflow and tooling, and example backend technologies that help with getting the remotely persisted data in a format that Ember and Ember Data can easily work with.
You may be asking why we are covering all these aspects of Ember.js development. Why not just build a frontend Ember app?
Well, before we lose you, rest assured we will cover all the basics you need in Chapter 1 and Chapter 2. The approach we take in the remainder of the book will hopefully provide more value and context. We feel there are numerous example applications that already provide the necessary beginner information. These applications are very valuable, as they provide the basics and are fantastic starting points. But when you try to meet the needs of a more complex application within the context of delivering a production product, many development teams get stuck not knowing where to start, which tools to use in development, and which backend technologies should be chosen to persist data.
Conventions Used in This Book
The following typographical conventions are used in this book:
- Italic
-
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
-
Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.
Constant width bold
-
Shows commands or other text that should be typed literally by the user.
Constant width italic
-
Shows text that should be replaced with user-supplied values or by values determined by context.
Tip
This icon signifies a tip, suggestion, or general note.
Warning
This icon indicates a warning or caution.
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/emberjsbook.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless youâre reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from OâReilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your productâs documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: âBuilding Web Apps with Ember.js by Jesse Cravens and Thomas Q Brady (OâReilly). Copyright 2014 Jesse Cravens and Thomas Q Brady, 978-1-4493-7092-3.â
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com.
Safari® Books Online
Note
Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the worldâs leading authors in technology and business.
Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.
Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like OâReilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.
How to Contact Us
Please address comments and questions concerning this book to the publisher:
- OâReilly Media, Inc.
- 1005 Gravenstein Highway North
- Sebastopol, CA 95472
- 800-998-9938 (in the United States or Canada)
- 707-829-0515 (international or local)
- 707-829-0104 (fax)
We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/bwa-emberjs.
To comment or ask technical questions about this book, send email to bookquestions@oreilly.com.
For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.
Find us on Facebook: http://facebook.com/oreilly
Follow us on Twitter: http://twitter.com/oreillymedia
Watch us on YouTube: http://www.youtube.com/oreillymedia
Acknowledgments
Many thanks for all the hard work provided by numerous individuals within the Ember community and of course, the Ember core team. The momentum and change within the community has created enormous challenges in building projects for clients and keeping the information in this book up to date. But it is all worth it when an API becomes more intuitive or a new feature is merged into core. Thanks for responding to our stack overflows and IRC questions and supporting the creation of this book.
Special thanks to all of our reviewers and editors at OâReilly, and to technical reviewer Adam Luikart.
And finally, thanks to our wives and families for supporting us throughout the authoring process.
Get Building Web Apps with Ember.js now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.