MGMLaboratory
Back

Menu

01Home
02About Us
03Projects
04Publications
05Member
06Articles
07Contact

Let's Talk

Open in Mail app

Socials

Malang (ID) --:--Privacy PolicyTerms of Service

September 1, 20162 min read

Porting a web algorithm into a reusable Android modulePorting a web algorithm into a reusable Android module

The RouteBoxer port shows what changes when browser code has to become a library that other projects can pick up.

  • Conference
  • Publications

Written by

  • SRShirasaka RenIT & Infrastructure · Student Member

In this article

  1. 01What changes when code becomes a library
  2. 02Document how the parameters scale

Reuse in software is often accidental. A helper written for one project gets copied into the next one, and then into the one after that. It keeps working until the platform changes, at which point every copy has to be fixed separately.

RouteBoxer is a small library for covering the area around a route with bounding boxes. It began life as a helper for maps in the browser. The Android version was not copied from anywhere. It was written as a library from the first commit, which changed several decisions along the way.

Everyday roads and signage. Route data drives the rectangles the library returns. Photo: LondekaT, CC BY-SA 4.0.
Fig. 01Everyday roads and signage. Route data drives the rectangles the library returns. Photo: LondekaT, CC BY-SA 4.0.

01/02

What changes when code becomes a library

  • The public surface has to stay small enough to document: a route and a distance go in, boxes come out.
  • It has to sit on the platform's own map stack, in this case the Google Maps Android API.
  • It should ship in more than one form: a compiled library file to drop in, or a source module to import and adapt.
  • Development stays inside the toolchain the target developers already use, here Android Studio.

Offering both a compiled artifact and an importable source module is the part teams skip most often. It costs little and it removes the main reason developers abandon a small library, which is not being able to change the one line they disagree with.

02/02

Document how the parameters scale

Navigation on a long trip. A wider corridor means far more boxes to query. Photo: Vyacheslav Argenberg, CC BY 4.0.
Fig. 02Navigation on a long trip. A wider corridor means far more boxes to query. Photo: Vyacheslav Argenberg, CC BY 4.0.

The most useful line in the paper is not about code structure. The authors report that the number of boxes grows exponentially as the requested distance increases. A caller who doubles the corridor width does not get twice the work, and without that fact written down they will find out in production.

The general lesson for anyone porting an algorithm across platforms is that the algorithm is usually the easy part. The platform API, the packaging, and an honest note about how the inputs scale are what determine whether the port gets used. A library that hides those costs is a library that gets ripped out later.

Source

  1. Pinandito, A., Saputra, M.C., Perdana, R.S. (2016). RouteBoxer library for Google Android platform. 2016 IEEE Asia Pacific Conference on Wireless and Mobile (APWiMob).

    DOI10.1109/APWiMob.2016.7811440 (opens in a new tab)

Next articleBounding boxes along a route, now as an Android library(Keep scrolling)(Read it next)(Loading)