Mobile Development

Badoo Londroid

Last night I went to a meeting of that alternative Java (i.e. Android) development group Londroid, sponsored by Badoo, a social networking tool, and hosted at Skill Matter/CodeNode. William Gibson once refered to Britain as Mirror World, like America but oddly different, and the same is true of Android to Java. It’s where the Java desktop world went when the internet turned up and everything went all server-side, so the meeting had a certain surreal quality for me.

Building a framework with Clean Architecture with Rich King
First up was Rich from the sponsor Badoo. Rich discussed how the Clean Architecure principals, as described in “Uncle” Bob Martin’s blog post, impacted on the development of the Badoo Android application. Here’s a description of Clean from the man himself:

What Rich described in his presentation is separating the parts of the system into domains (shades of DDD here), usually done in the Java world when designing for a Microservice architecture. Because of the limited nature of the Android platform, all this is in what might be described as a micro-monolith (think there’s a niche for nano-services on Android?). All-in-all a nice presentation, only spoilt by ghost transmissions from the presentation upstairs.

Presentation Patterns Using Rx with Yoel Gluschnaider and Flavio Zanda
Although there are few Spring-like frameworks in Android, again due to the limitations of platform, RxJava has taken off, mostly as a more sophisticated option or supplement to data-binding.

However, there’s still a need for what frameworks usually implement, in this case the Model-View-Controller (MVC) design pattern for managing the interactions between the screen and what goes on the the back. Alternatives to this pattern are the Model-View-Presentor (MVP) and the Model-View-ViewModel (MVVM) patterns. The former, and the one they recommended, is a variation on MVC pattern and, like this, the view makes a request to the controller and the controller consults the model about how to respond. MVC assumes the controller is pretty dumb, just acting as a junction box separating the View from the Model. MVP moves most of the decision making to the controller, to the point that View does almost nothing (a Passive View pattern, as it’s been called). MVVM is more complicated, by the sounds of it, and I haven’t had time to do any research on it at the moment, but that also looks interesting.

Yoel and Flavio’s talk was very engaging and interesting, despite it’s short length.

IoT Innovators Meetup: Meet the BBC micro:bit with Howard Baker

Earlier this evening, I went along to a new group meeting at Canonical (the organisation behind Ubuntu) on London’s South Bank, behind Tate Modern. Nice offices:

The presentation was given by Howard Baker who is a lead at BBC Learning looking at innovating technologies.

His talk was about the background to the micro:bit, the BBC’s initiative to promote software development in schools through a micro device.

It turns out that software development is not taught at schools, something that astonished me, and that Universities complain that the entrants to Computer Science courses have to be taught basic programming skills. In answer to this. the current Director General of the BBC wants an initiative to promote programming, in the same way the Model B did all those years ago. Everyone has a computer these days so, after a few false starts, Howard and his team came up with the micro:bit. It has a small ARM chip, a magnetometer, accelerometer and a neat little 5 X 5 led display, along with a low power blu-tooth transmitter/receiver. It also has a mini-USB port and external analogue/digital connector.

It’s also got a nice web site with on-line editors for producing code to run the hardware: one in a Scratch-like block language, which translates into Microsoft’s Touch Develop language, and one for JavaScript. There will, hopefully, be a Python one as well.

The goal is to roll out the device to 1 million children of 11-12 year old’s (1st year secondary). Howard emphasised the social aspects of the program, saying that it wasn’t just aimed at the children but that the parents could see their children being creative and enthusiastic. In particular, he said that he thought that the idea of owning the technology and making it themselves was fundanental, turning children “from consumers into creators”, being influenced to some extent by the Maker movement.

Overall, it was an excellent presentation on an engaging subject.

Android Livecode, RxJava Architectures on Android at Microsoft

This was an Android Livecode presentation I attended, hosted at the Microsoft offices in sunny Westminster.

After the introduction, the main presentation was given by a Berliner, Timo Tuominen from Futurice, concerning the use of Functional Reactive programming on Android. This centred around the use of RxJava, an open source library based on a Microsoft library and implemented by Netflix, the video streaming company.

(A well attended presentation, as you can see, but there was free beer and pizza).

RxJava is centered around the use of an Observable class i.e. an implementation of the Observer design pattern from the “Gang of Four” book, on which most event model are based. It seems that the difference between, say, the standard Java listeners and RxJava is that the listeners have to be implemented within the class as you’re coding it. Here’s something I’ve been working on for the College:

//custom event maintenance
//this is a list of events that have to
//be serviced when something happens
private List<SwitchListener> listenerList = new ArrayList<SwitchListener>();

public void addSwitchListener(SwitchListener listener) {
    listenerList.add(listener);
}

public void removeSwitchListener(SwitchListener listener) {
    listenerList.remove(listener);
}

private void fireSwitchListener() {
    //parcel up the state of the switch in a SwitchEvent object
    SwitchEvent e = new SwitchEvent(this, isSwitchOn());
    //then send it to every listener in the list
    for(SwitchListener listener: listenerList) {
        listener.switchChange(e);
    }
}

Listeners are all over Java components as it provides a way of passing messages between the components and their containers without the components having references to the latter (a problem known as “coupling”).

What RxJava seems to do is wrapper up listeners, or something like them, into a framework that can be applied to any other object. For example, if you want to “listen” to an object so that when it changes you can do something else, or react to it, you can use the Observable class to do it:

Observable.from(names).subscribe(new Action1<String>() {
    public void call(String s) {
        System.out.println("Hello " + s + "!");
    }
});

It does seem to be something that you would think was already in function programming languages, like Clojure and Scala, by default, but RxJava can be used by these, so maybe it isn’t?

Android Programming

I’ve started a course in Android programming using the Hello Android! book by Ed Burnette:

The idea is to use building a Sudoku game as guide to building Android applications using Java and XML.

After downloading the latest Android development kit from Google, you unpack it (it’s a zipped folder) and run the SDK manager. This allows you to further download bits that you might need, such as different versions. At time of writing, the latest version is 4.1, but this is known as API 17 as well, which can sometimes be a bit confusing. Included with the kit is an emulator run by the Android Virtual Device manager:

Android_Emulator

You can either create a device from scratch or, perhaps better, you can switch to the Device Definitions tab and create a ADV from one of the devices defined. One of the definitions which can be useful is that the camera can be mapped onto your PC’s web cam. Although you can run the ADV manager from the Eclipse IDE, it’s better to run it seperately just in case either crashes.

The kit also comes with a copy of Eclipse with the plug-ins pre-installed so you can get up and running straight away. As well as being able to edit the Java code, there is also a layout designer:

Eclipse_Android

Layouts, menu’s, strings, colour definitions and so on are all considered resources and are contained in XML files.