b-log – betriebsraum weblog

Software Development, Human-Computer Interaction, Projects…

The PROTIUM mobile application architecture for iOS and Android

November 1, 2016

Protium Logo
Protium is an architecture for mobile applications on iOS and Android. Like many other architectural approaches, it should merely be seen as suggestion rather than panacea for solving all mobile development projects. Protium attempts to apply solid software engineering principles while capturing modern development practices. Protium is not a framework, meaning that you are not forced to use or subclass any components. Instead can freely choose which conceptual building blocks you wish to apply and integrate. The main goal of the architecture is to encourage consistent code organization using elements with clearly defined roles (or Separation of Concerns).

The model has successfully been applied in a number of projects and constantly been refined (the latest version, Protium v3 applies reactive programming). If you are new to mobile application architecture or struggling with finding a suitable approach for larger projects, even if you don’t apply the entire architecture, you might find some ideas in this document on how to structure your next project.

View the project on Github
View the Github page

Swifty Circuit Breaking

February 9, 2016

Circuit Breakers are most useful for networking where remote calls can fail or time out at any moment. When configured thresholds are reached, the circuit breaker “trips” and thus prevents putting unnecessary load on the server until the breaker resets itself after a timeout. In addition, my Swift implementation provides convenience features such as monitoring call timeouts and supporting retry logic with exponential backoff.

View the project on Github

A fast gesture recognizer based on the PennyPincher algorithm, written in Swift.

August 9, 2015

Penny Pincher is a fast template-based gesture recognizer, developed by Eugene Taranta and Joseph LaViola (full paper reference below). The algorithm is well-suited for mobile applications since it is both fast and accurate and, as shown in the evaluation by the authors, outperforms other recognizers. My Github project provides a Swift implementation of Penny Pincher and shows its usage in a simple example project. Also, the framework contains a UIGestureRecognizer subclass that integrates well into the existing gesture recognition framework of iOS.

Here’s the full reference for the paper:

Eugene M. Taranta, II and Joseph J. LaViola, Jr.. 2015. Penny pincher: a blazing fast, highly accurate $-family recognizer. In Proceedings of the 41st Graphics Interface Conference (GI ’15). Canadian Information Processing Society, Toronto, Ont., Canada, Canada, 195-202.

View the Github page

Using Swift to Predict Revisitations and Reuse

July 4, 2014

AccessRank is a Swift implementation of the AccessRank algorithm by Fitchett and Cockburn (full reference below) for iOS and Mac OS apps. The algorithm predicts which list items users might select or visit next by taking multiple sources of input into account. For instance, you could use AccessRank to generate a list of predictions for:

To improve on other common methods such as recency-based and frequency-based predictions, AccessRank adds Markov weights, time weighting, and other parameters for calculating a final score for each item, while the algorithm tries to maximize both prediction accuracy and list stability. Prediction accuracy is important since top items are easier and faster to access than items in bottom sections; list stability is important since automatic reordering of items can impede usability when users try to reselect an item based on an already learned location. You can configure the algorithm depending on whether you prefer more prediction accuracy or more list stability.

Once AccessRank has calculated predictions, you can use the resulting list to enhance your user interface in various ways. For example, you could display the most likely next items in an additional list as suggestions, or you could visually highlight relevant objects to give users cues where they might want to go next.

Here’s the full reference for the AccessRank algorithm by Fitchett and Cockburn:

Stephen Fitchett and Andy Cockburn. 2012. AccessRank: predicting what users will do next. In Proceedings of the SIGCHI Conference on Human Factors in Computing Systems (CHI ’12). ACM, New York, NY, USA, 2239-2242.

View the Github page

Improving iOS Target Selection for Finger Touch Using the Bayesian Touch Criterion

June 9, 2014


BayesianTouchCriterion on Github

BayesianTouchCriterion is an Objective-C implementation of the Bayesian Target Criterion (BTC) developed by Xiaojun Bi and Shumin Zhai. Given a touch point and some touch targets, it improves the accuracy of selections by finding the touch target with the shortest Bayesian Touch Distance (BTD). This element is the one that the user intended to select. The results of the evaluation of Bi and Zhai show that selection based on BTC is much more precise than using the visual boundary of an element. (Visual boundary checking is how most touch frameworks determine if the finger touches a target.)

The image above shows how randomly placed touch points (the smaller, semi-transparent circles) select their corresponding targets (the nine big circles). In the user interface of a mobile app, for example, BTC could be used to more accurately determine which menu item the user intended to select. The point of using BTC instead of visual boundary checking is: The intended element is not necessarily the element where the user’s touch lies exactly within the visual boundary of the element (e.g., the touch point might be somewhere slightly outside of the visual boundary). BTC has the advantage that it does not require more detailed information about the touch point (finger posture, touch area…). The only required input parameters of the formula are touch location, target center, and target diameter.

If you are interested in the full mathematical details and derivations, here’s the full reference:

Xiaojun Bi and Shumin Zhai. Bayesian touch: A statistical criterion of target selection with finger touch. In Proceedings of the 26th Annual ACM Symposium on User Interface Software and Technology, UIST ’13, pages 51–60, New York, NY, USA, 2013. ACM.

The paper is freely available on Research at Google.

Plumber: Objective-C library for Curved Connection Lines

February 5, 2014


Plumber on Github

Plumber is a tiny Objective-C library for creating curved connection lines between nodes (for flowcharts, for example). The constructed path connects the bounding boxes such that the distance between two sides is minimized. I’ve created it since a quick Google search did not reveal anything simple for iOS. The curve calculation algorithm is a direct port of the function used in the Graffle Example of the vector drawing library Raphaël.

CodingKeys: Unified keyboard shortcuts for your development tools

November 19, 2013


CodingKeys on Github

Nowadays, developers often work in several different development environments and text editors. For example, you may need Eclipse for regular Java development, Android Studio for Android development, Xcode for iOS development, Visual Studio for C#, Sublime Text for web development, etc.. Every tool, however, has different keyboard shortcuts. Since it is hard to remember all shortcuts, there’s a constant loss of productivity when switching tools. If you don’t want to edit all shortcut sets in every tool, you can instead use CodingKeys as an “abstraction layer”.

CodingKeys lets you define unified shortcuts, which are dynamically re-mapped to existing shortcuts of other applications when you switch tools. All mappings can be conveniently edited in a single configuration file. The config file also gives you a nice overview over all shortcuts and grows as you add new apps to your coding toolbox.

Advanced Gesture Recognition in iOS

November 30, 2012

DollarP-ObjC is an Objective-C port of the $P gesture recognizer to be used in iOS applications.

$P Demo iPhone App

What is $P?
From the $P website:

The $P Point-Cloud Recognizer is a 2-D gesture recognizer designed for rapid prototyping of gesture-based user interfaces. In machine learning terms, $P is an instance-based nearest-neighbor classifier with a Euclidean scoring function, i.e., a geometric template matcher. $P is the latest in the dollar family of recognizers that includes $1 for unistrokes and $N for multistrokes. Although about half of $P’s code is from $1, unlike both $1 and $N, $P does not represent gestures as ordered series of points (i.e., strokes), but as unordered point-clouds. By representing gestures as point-clouds, $P can handle both unistrokes and multistrokes equivalently and without the combinatoric overhead of $N. When comparing two point-clouds, $P solves the classic assignment problem between two bipartite graphs using an approximation of the Hungarian algorithm. The $P recognizer is distributed under the New BSD License agreement.

More on my Github page.

Tuio.js: Multitouch and tangible interaction in the web browser

May 24, 2012

Tuio.js is a JavaScript implementation of the TUIO library for multitouch and tangible interaction in the web browser. It brings a 1:1 port of the original TUIO Java library.

How it works
TUIO is based on the OSC protocol and usually transferred via UDP. Tuio.js uses node.js and Websockets (Socket.IO) to push OSC/TUIO messages to the browser. TUIO.js converts the messages to events that applications can register with.

More on my Github page.

Why Facebook App Development is Seriously Flawed

August 24, 2011

Recently, the facebook API has been voted »Worst API« in a developer survey. Bad news first: It really is the worst API (or at least the worst API that we have worked with). Good news: It would be quite straightforward for facebook to drastically improve the overall app development experience by working on at least one specific area (see end of this article).