A Few Best Practices For Building Static Clients

Frank Dou
on September 25, 2013

The teams at Wiredcraft and devo.ps shifted to building static clients and APIs in the backend a while back. We wrote about it and are excited about the potential we see in this approach; it is nothing novel but became a more common strategy for Web apps with the rise of front-end frameworks such as Backbone.js, Ember.js or AngularJS.

Things in this space move extremely fast, making it difficult to find up-to-date best practices. It took us a painful amount of time to find out what works and what doesn’t, we thought we’d share some of the tools we rely on to get the job done. Most of this is captured in feathers, a boilerplate for building AngularJS front-end applications that we’ll release in a few weeks.

AngularJS

While we initially settled for Backbone.js + Marrionette.js, we moved over most of our products to AngularJS.

Backbone is built on top of jQuery and underscore.js, provider us with model collection, routers and other basic tools which make build web application much easier.

And Marrionetter.js, its good atview management, it makes code organisation looks more nature and easy to understand.

But when app getting large, it become a nightmare to maintain and develop.

Bower and npm

Separation of concerns (Bower + npm + component…) I just want start ot write my code and I do not want to fecth libraries manually. And below is what we think thoes package management tools can bring us:

npm - back end or whatever, nodejs community is awesome because of npm

create and manage modules, open source, share and learn…

There’s no much need for us to tell you how to use npm or bower, but a hint may also help: add an additional .bowerrc file to specify the location of modules you’d like to place:

{"directory":"vendor","json":"bower.json"}

Testing

Every developer here at Wiredcraft know things about back-end, and we usually don’t code without write tests, So we know the importance of test.

Fortunately, the angular team is also a super fun of testing. Karma it’s the best example compare to other mvc frameworks, and this is also one big reason for us to choose angularjs.

For testing angularjs application, truth be told, we’re just get started it, we can not share to much experience with you, but we do recommend this [http://www.yearofmoo.com/2013/01/full-spectrum-testing-with-angularjs-and-karma.html
], it does a great job by explaining what is unit test, middle way test and end to end test, if you want to write better code, you must read it!!!!