On January 30th at events all over the world, RIM introduced Blackberry 10 its brand new mobile operating system that is designed to take the fight to iOS and Android.
Blackberry 10 and its new handset, the Z10 were well received but blogs, websites and twitter comments can only get you so far; luckily I attended Blackberry Jam Europe 2013 in Amsterdam to get a closer look at the platform and its developer community. Over two days, hundreds of developers met at the sold out RAI convention centre to discover new features, case studies and trends introduced with Blackberrys latest mobile platform..
As I watched the keynotes and attended various break out sessions I was motivated by the potential of this new technology, so I decided to program a simple application for Blackberry 10. This post explains a little bit about the experience, describing the application and some parts of the code. As always, you can find the source code in the GitHub account, released with Apache 2.0.
SmartSeq
The project was a simple game, called SmartSeq. The game challenges the user with a sequence of letters, letting the user to guess the intrinsic pattern. As part of the game, I programmed three different sequences:
- Natural sequence: abcdefghi…..
- Even sequence: acegik….
- Fibonacci sequence: aabceh….
Nonetheless it can be extended very easily with other mathematical sequences. In addition, to be more complete, the game should include offline storage of the scores, and some social integration. However, the initial release is enough to evaluate the development environment for BlackBerry 10.
Programming UI with Cascades
Cascades is a new framework, based on Native SDK and using Qt Libraries. The QNX Momentics IDE allows developers to create great user interfaces, highly integrated with C++ code. User Interfaces are programmed using QML, standing for Qt Modeling Language. Basic UI looks like this:
import bb.cascades 1.0
// creates one page with a label
Page {
// Binding with c++ code property alias sequenceText: sequence.text
// Basic container declaration Container{
layout: StackLayout {
{ horizontalAlignment: HorizontalAlignment.Fill verticalAlignment: VerticalAlignment.Fill
}}
You can take a look of the whole code here. Basically, the user interface includes some labels for information output and two input fields: a text field and a button. You have an UI diagram below:
It is worth mentioning the way Cascades binds QML objects with C++ code, fields are defined in QML by simply adding references in the QML file:
property alias sequenceText: sequence.text property alias scoreText: score.text property alias clueText: clue.text property alias answerText: answer.text property alias answerEnable: answer.enabled
Then, you can read / write values from these fields from C++ simply using the following code:
_root->setProperty(“clueText”,_clue_format.arg(initialSeq));
_root->setProperty(“sequenceText”,_sequence);
_root->setProperty(“scoreText”,QString(“%1 pts”).arg(_score));
To publish variables/objects in C++ code is also quite simple and to make them accessible from QML you only have to code the following:
// create scene document from main.qml asset
// set parent to created document to ensure it exists for the whole application lifetime QmlDocument *qml = QmlDocument::create(“asset:///main.qml”).parent(this);
// create root object for the UI _root = qml->createRootObject(); qml->setContextProperty(“SmartSeq”,this);
Logic with pure C++
The underlying logic of BlackBerry 10 apps C++, our example game is pretty simple and you can view the declaration on SmarSeq.hpp . The class diagram is below:
Finally, the three methods from SmartSeq.cpp
- SmartSeq::startGame
- SmartSeq::updateGame
- SmartSeq::resetGUI
implement the dynamic behaviour of the game. As you can see, if you would like to extend the game, only have to implement the virtual class Game with another funny sequence.
Conclusions
Honestly, I have found the new Blackberry 10 framework to be very interesting, although I must confess that my mother programming language is C++, so there are many common ideas, which are part of my developer skills. However, for most mobile developers, coming mainly from existing platforms and web programming, the C++ nature of Blackberry 10 can create a high entry barrier to the platform. Fortunately Blackberry is aware of this and are working with PhoneGap, Appcelarator to enable easy cross plaform porting and have enabled Android developers to use their existing apps on the platform.
In any case, the documentation, code snippets and IDE (an Eclipse customised) are very appealing. In addition, QNX is a real operating system used on a variety of different devices, not just mobile and so does without many of the limitation you can find in other customized mobile platforms. My feelings are that all of this could help Blackberry to engage an even bigger developer community. My only concern is that you will need to pay a VMware Fusion license to use the BB10 simulator. Even though it is cheap, it introduces an unnecessary entry barrier for developers. However, perhaps that is precisely what Blackberry is looking for: developers who are willing to invest in the platform.
So in closing, congratulations to the Blackberry 10 team, you have created a flexible mobile platform that is much easier to develop for, in short you have done a very good job.

















Recent Comments