Black and White
When writing unit tests using mocks, it forces the developer into whitebox testing. As the tests are supposed to drive the design, one can argue that this allows them to define the dependencies of the business logic in which they are writing the tests. The quandary, though, is that these tests are no longer unit tests as there is a discrepancy between a single unit and a system of functions that interact with many units or dependencies. Furthermore, tests that rely heavily upon mocks wind up with a test suite that has mocks mocking mocks mocking mocks and so forth, which can lead to a broken test suite any time a programmer tries to refactor in, or out, another dependency.
An Alternative Approach
This post is an overview of an alternative approach to attaching Reveal or Spark to third party apps on a jailbroken device. Peter Steinberger posted a blog post demonstrating how this works using MobileSubstrate. Unfortunately, this approach didn’t work for me and a few others that shared my woes via Twitter.
UIColor
UIColor
is a commonly used class that represents color and sometimes opacity. As it turns out, UIColor
is a class cluster made up of a couple of private concrete subclasses.
Class clusters group a number of private concrete subclasses under a public abstract superclass; this is based on the abstract factory design pattern.¹
Trampolines
A trampoline is a small piece of code that is created at run time when the address of a nested function is taken.
It normally resides on the stack, in the stack frame of the containing function. The word trampoline is used because execution jumps
into the trampoline object and then immediately jumps out.¹
The builder pattern is a creational design pattern. It is used to abstract steps of the construction of complex objects from its representation so that the same construction process
can create different representations.¹
Complex objects that the builder pattern can be useful towards, for example, include building mazes, characters in video games, and perhaps even baking. However, these examples are
somewhat of a stretch and don’t provide any common ground for beginners. One thing I’ve found the builder pattern to be useful for is for building attributed labels.