Summary

Hopefully, walking through how the Brew Everywhere application is put together has helped you to see how we can use different services to build a first rate application.

We followed AngularJS best practices to partition our code across controllers, directives, models, and services. We kept our controllers as thin as possible by using controller inheritance to encapsulate common code across the controllers into a base controller that each controller inherits from by using the $controller service.

We used directives to encapsulate code that manipulates the DOM and validate data. This again follows best practices by limiting DOM manipulation to the correct component and helps to keep our controller as thin as possible by moving validation code out of the controller to directives where it works best.

Next, we used value providers to define the models used within our application to provide both state and function to our models. We saw how this comes in handy when we need to iterate through arrays of model objects to calculate beer style parameters.

Finally, we used services throughout the application to manage data, control application flow, and interact with external services to reduce the amount of code we needed to build out the functionality of our application. In fact, if you notice, the Brew Everywhere application does everything without a dedicated server running in the background. Data used by the application is stored in the cloud via mongolab.com; calendar events and tasks are stored and managed by Google's Calendar and Tasks services. The application even utilizes Google+ and Facebook to authenticate users of the application.

Our core business logic is also encapsulated in specialized services such as finite state machines and rules engines, allowing us to change the business logic or rules set on the fly based on where in the application the user happens to be.

We also followed the best practice of single responsibility per component especially in our data-access services. We built services that specialized in managing each of the data models used in our application and then leveraged generic services to interact with the external services used to store the various data.

Hopefully this book and the services discussed will inspire you to look at your AngularJS applications differently and think about how you can leverage services to make your application more robust, better architected, and easier to maintain. Just remember, with a good library of services at your hands, you have a toolset that you can use to build just about any type of application you need.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.227.9