In my earlier posts on Rich Object Models and Angular.js and Angular Identity Maps I’ve shown how, by introducing a rich object model to your Angular.js application, you can begin to employ more sophisticated techniques for modelling your business domain.
In this post I’m going to demonstrate how we can simplify business logic by using getter methods to hide complex calculations behind properties. Furthermore, we’ll do it in a way that slots in nicely with our existing rich-object model. If you don’t feel like reading, you can check out the section of my ng-conf presentation that covers this or go straight to the Github project.
Mobile web apps have come a long way from their clunky, cut-down ancestors of the pre-smartphone era. Responsive design and mobile-specific interactions such as touch and swipe events have begun to bridge the gap between mobile web-apps and native smartphone applications. So unsurprisingly, when working with a mobile web app we are often tasked with aiming not only for feature-parity with a corresponding native app, but for UI-parity as well.
While plenty of arguments can be made against this approach to begin with, on a recent mobile web-app project we were curious to see how far we could go when tasked with pursuing the native ideal.
Parity across the layout of the pages is simple enough, but the native UI experience is about so much more than just layout. All of the seemingly-insignificant things in the periphery – page transitions, modal dialogs, the now ubiquitous left-hand slide-in navigation bar – are crucial. However, there was one element that we didn’t expect to cause any problems, particularly given how widely used it is – the humble accordion.
In my previous post on Rich Object Models and Angular.js I introduced a simple strategy for setting up rich object-models in Angular.js. It turns out that once we’ve introduced the notion of a rich object-model, a number of more advanced object-oriented programming techniques become easy to implement. The first of these that I’m going to discuss is identity maps.
In this post I’m going to talk about what an identity map is, why you might need one, and I’ll introduce a simple identity map implementation for Angular.js. I’m going to assume you’ve already read my foundational post. If you’d like to see the portion of my talk at ng-conf devoted to identity maps, jump to the video.
I was recently lucky enough to get a hold of a couple of sets of Bluetooth low-energy beacons; three Estimote beacons and a set of five Kontakt beacons. Whilst the Estimote beacons sure looked a lot fancier, I was keen to see if it was all just for show, or if they truly were a superior product. So I got to work putting them through their paces by conducting some controlled experiments to test their behaviour. Throughout the rest of this post I’m going to discuss the results of these experiments and conclude with some observations on their real-world usefulness for providing proximity-based services.
Posted in iPhone
Tagged bluetooth, iOS
As a newcomer to PHP I was puzzled by how to unit test controllers and services when using Silex (if you’re wondering, Silex is based on the Symfony 2 framework and draws a lot of modules from it).
In this post I’ll talk about my experiences getting tests going, and how you can setup your own unit tests using PHPUnit and WebTestCase. I’ll start with my initial attempts to test directly against the DB, and the approach that I ultimately found most useful and practical.
I’ve also created an example Silex project that can be used to try out the various features of PHPUnit. The only prerequisite is PHP 5.4, which comes with most modern OS’s. You don’t even need Apache installed to try it out!
Another sort of rich model
Services are singletons, so it can be unclear as to if and how you can group per-object state and behaviours. Consequently, people tend to fall back to services that deal in very simple JSON objects – i.e. objects that contain only data, not behaviour. However, building the sorts of rich interfaces that our users demand means that we sometimes need to more fully leverage the MVC pattern. Put differently, for some problems it can be useful to have a rich object model that provides both data and behaviour.
Recently at ng-conf, I presented a simple approach I’ve used for using rich object models with Angular.js. This technique leverages existing frameworks, maintains testability, and opens up a range of possibilities for more succinct and easy-to-understand code. In this post I’ll outline the underlying approach, but you can also find some (very simple) helper code here.
Shine Senior Consultant Ben Teese spoke last week at ng-conf, the world’s first Angular.js conference. The two-day event was held in Salt Lake City and featured both the Angular core team and Angular experts from around the world. Being a single-track event, Ben had the attention of all 700 attendees as he spoke about Rich Object Models and Angular. Video of his talk is now available online, as well as the slides. Take a look and let us know what you think!