Tuesday, 24 December 2019


I struggle to remember what the ASCII, ISO and UTF acronyms stand for so I'm typing them up here in the hope that they stick!
  • ASCIIAmerican Standard Code for Information Interchange: this is the 7-bit character encoding system (7 bits so a total of 127 characters) and forms the basis of the other two systems.
  • ISOInternational Organisation for Standardisation: this is the 8-bit character encoding system which has a number of different versions each supporting a different set of languages (e.g. ISO-8859-1, ISO-8859-2 etc).
  • UTFUnicode Transformation Format: this is the system which uses a variable number of bytes (usually 1-4) to encode a character and hence supports a significantly larger number of characters than the other two systems.

Friday, 11 October 2019

iOS: Natural text alignment doesn't mean what you think it means

So it turns out that natural text alignment in iOS doesn't mean "left-align left-to-right text and right-align right-to-left text" as it does in Android. For example, if I put English text in a UILabel I'd expect it to be left-aligned and if I put Arabic text in a UILabel I'd expect it to be right-aligned. But no. This is not how it works in iOS. Instead natural text alignment in iOS means "left-align text if the device's language is set to a left-to-right language and right-align text if the device's language is set to a right-to-left language". So, for example, if I set the device's language to English then the text in the UILabel will be left-aligned regardless of its content and if I set the device's language to Arabic then the text in the UILabel will be right-aligned regardless of its content.

For a super simple iOS application which demonstrates this see here.

Friday, 9 August 2019

Quran SDK (library) for iOS

I mentioned a good while previously that I'd extracted code out from my Hifdh Tracker and Hifdh Tester Android apps into a Quran SDK for Android. Well I've just started porting these apps to iOS and as a first step I've ported the Quran SDK for Android to its iOS equivalent. The Android and iOS SDKs are essentially Kotlin and Swift (respectively) wrappers around the Quran database which make it super easy to get data out of the database. You can find the repository for the SDKs here. The README in the repository explains how to incorporate and make use of the SDKs in your own Android and iOS projects.

Friday, 5 April 2019

Android: Display bulleted list in a TextView

The BulletSpan class in Android has some quirks about it which makes it a little difficult to use. For example, each character sequence which is to be bulleted has to be preceded by a new line character. And using BulletSpan alone you're not able to specify how much vertical space you want between each bulleted character sequence. For this reason I've put together a Kotlin extension function on the SpannableStringBuilder class named appendBulletSpans(...) which takes the difficulty away from creating a bulleted list.

You can use this extension function as follows:

val spannableStringBuilder = SpannableStringBuilder()

spannableStringBuilder.append("Here is a list of fruits:")

    paragraphs = arrayOf("apple", "banana", "carrot"),
    putVerticalSpaceBeforeFirstParagraph = true,
    verticalSpaceToPutBetweenParagraphs = verticalSpaceInPixels,
    horizontalSpaceToPutBetweenBulletPointAndParagraph = horizontalSpaceInPixels,
    bulletPointColor = Color.BLACK

textView.text = spannableStringBuilder

This will render the text in a TextView as follows:
You can find the source code for this extension function in the SpannableStringBuilderExtensions.kt file in this repository.

Friday, 7 September 2018

Book Review: Pivot – Real Cut Through Stories by Experts at the Frontline of Agility and Transformation

This was an alright read. Some of the contributions I thought were a bit on the theoretical side which wasn't what I was expecting judging by the title but there were some good real life examples mixed in. Some of the points that stood out for me were (1) the importance of differentiating between Agile the process and agility as a mindset, (2) understanding that being agile and willing to change a product's direction is a good thing but changing direction doesn't come for free and (3) having a hero culture in an organisation is bad without exception.

Below is a small selection of excerpts from the book:
"Having even just a few people in hero positions can be a sign of bad leadership."
"Leaders should foster environments where the team as a whole is valued and appreciated. It is not to say that we shouldn't acknowledge individual efforts. After a job well done and recognising the team, if you feel someone deserves more, tell them in person."
"I recommend replacing the demand for heroism and sacrifice to setting a goal of sustainable goals. As a result, the team becomes confident in their abilities without the hero of the team."
"The traditional image of heroism does not fit all-stars agile team."
"A leader should be equipped to spot both a culture of hero worship and individuals who engage in self-sacrificial behaviour at the cost of long-term sustainability."
"No more heroes."
"Knowing your organisations purpose and creating a unified vision spanning organisational silo together with cross-team collaboration is essential to delivering value and maintaining market relevance. Nokia's high performing Agile teams, did not stop it from losing huge market share to Apple and Google in the upper end of the smart phone market.  Being Agile is not enough."
"There is no world where feedback doesn't take time to implement. If this is a project with an agreed delivery date, when the client gives you feedback, you need to manage expectations and move the goalposts. Change doesn't come for free. Adapting to change is a two-way thing."

Friday, 11 May 2018

Types of Test Doubles

Think of a test double as a pretend object used in place of a real object for testing purposes. Below are four kinds of test doubles that you will encounter.


  • An object that is passed around but never used.
  • Used to help fill parameter lists or fulfil mandatory field requirements where the object will never get used but gets the code to run.
  • In many cases it's just an empty or null object.


  • An object that always returns the same canned response.
  • Used when you want to replace a real implementation with an object that will return the same response every time.


  • An actual working implementation (close to but not of production quality or configuration) that can replace the real implementation.
  • Can be seen as an enhanced stub that almost does the same work as the production code but takes a few shortcuts in order to fulfil the testing requirements.
  • An example is an in-memory database (used instead of a real, persistent database).


  • An object that represents a series of expectations and provides canned responses.
  • Can be seen as a programmable stub which can be told the sequence of calls to expect and how it should respond to each one.
  • Combines well with Dependency Injection in that it allows pretend objects to be injected that will behave in precisely known ways.

(Source: The Well-Grounded Java Developer, by Benjamin J. Evans and Martijn Verburg)

Friday, 9 February 2018

Book Review: The Well-Grounded Java Developer, by Benjamin J Evans and Martin Verburg

Although Java 9 is now out and this book was written way back when Java 7 was new I still found this to be a very useful and educational read. The book explains the fundamentals of the Java platform (e.g. bytecode, garbage collection) and programming principles in general (e.g. concurrency, dependency injection, functional programming) in a way that I've not seen in any other book. The introduction and contrast of the Groovy, Scala and Clojure JVM languages I also thought was done well. Some aspects of the book are now dated but it's still worthwhile skimming over for a historical context of how the platform has developed. If you're new to programming and new to Java development however this probably isn't the right book to start with.