Quantcast
Channel: XPlorations Archives - XP123
Browsing index pages (123 articles)

Image may be NSFW.
Clik here to view.

Betwist(tm): Evolutionary Design of a Trie

I’m building Betwist(tm), a word-finding game related to Boggle®. You’re given a repeating grid of letters, and find words by moving from letter to letter. We start with a dictionary, the set of all...

View Article


Image may be NSFW.
Clik here to view.

AAA and the Object Lifecycle

We’ll look at how Arrange-Act-Assert (AAA) tests reflect the lifecycle of the objects we’re working with. Object Lifecycle An object has a basic lifecycle: create (command | query)* (abandon | delete)...

View Article


Image may be NSFW.
Clik here to view.

“Test Interface, Not Implementation”

“Test Interface, Not Implementation” Perhaps you’ve heard the phrase “Test interface, not implementation”, or its relative, “Test behavior, not implementation”. We’ll look at this from the TDD...

View Article

Image may be NSFW.
Clik here to view.

How to Reduce Coupling, Three Ways

Two objects are coupled if changing one requires us to change the other. (See Yourdon and Constantine.) We’d like to reduce coupling, since it makes changing code more complicated. A change in a...

View Article

Image may be NSFW.
Clik here to view.

Reordering Items, Four Ways

Recently I needed to implement a drag-and-drop reordering, with persistence. At least with SwiftUI, reordering is easy if it’s all in memory: you have an array of items, the UI tells you which ones...

View Article


Image may be NSFW.
Clik here to view.

And-Or Trees

Suppose you want to represent a finite set of possibilities in a compact way. An And-Or Tree can do this, and is useful in several situations. An And-Or Tree has leaf nodes and interior nodes. The...

View Article

Image may be NSFW.
Clik here to view.

Run Tests Without an App — Step by Step with Xcode

I’m frustrated when unit tests run slowly. One way to speed them up in Xcode when developing using a simulator: isolate your model to a framework, and run your tests without a host application....

View Article

Image may be NSFW.
Clik here to view.

Swift Testing – A New Unit Testing Framework

Apple has introduced a new unit testing framework. It has a simpler syntax, much simpler assertions, parameterized testing, and more. Let’s take a look. You can find a bonus cheatsheet at the end of...

View Article


TDD with a Function Pipeline

Our “geek” group tackled a problem a couple weeks ago, that one of us had heard suggested by Michael Feathers: given a sequence of numbers, tell how many non-zero runs it has. Ron Jeffries described a...

View Article


Image may be NSFW.
Clik here to view.

Trees – Confidence in Design

Test-Driven Development (TDD) depends on assembling well-tested parts into a trustworthy whole. Some design structures make this easier. Today, we’ll look at trees. A tree is a structure consisting of...

View Article

Image may be NSFW.
Clik here to view.

Pipelines – Confidence in Design

The other day, Kent Beck pointed out a skill that test-driven development (TDD) relies on but doesn’t give much guidance about: “behavioral composition”. This is the skill of dividing a big behavior...

View Article

Image may be NSFW.
Clik here to view.

Threaded Code (and Composite)

Let’s look at the threaded code approach. It’s a less-well-known way to build an interpreter for a programming language. (The more common approach simulates each instruction.) Threaded code has a...

View Article

Image may be NSFW.
Clik here to view.

Time Troubles – Transitions

Time is a well-known source of trouble for programmers. We looked earlier at one type of time troubles: overflow. Today, I’d like to look at another time trouble: transitions. Here are the problems...

View Article


Refactor: Inline-Adjust-Extract

Sometimes, we feel that something we extracted isn’t as good as it could be. The Inline-Adjust-Extract refactoring pattern can help fix that. It has three steps: Inline: put the extracted code back...

View Article

Organizing Fields and Methods

When you’re making a class, in what order do you put the fields and methods? We’ll look at several choices and some tradeoffs between them. Organizing Fields I’ve seen a few approaches to organizing...

View Article


Image may be NSFW.
Clik here to view.

Reduce Dependencies Using Lambda

When A depends on B (A → B), a change in B may force A to change as well. Dependencies are both good and bad: they let objects work together, but they make software harder to change. We can use lambda...

View Article

Image may be NSFW.
Clik here to view.

Iterative Enhancement and XP-Style Design

“Iterative Enhancement” is a model for iterative development, from Basili & Turner, described in 1975 (!). We’ll look at it, and compare it to XP’s approach. I’ve seen occasional mention of this...

View Article


Image may be NSFW.
Clik here to view.

Refactoring: Extract Local Lambda

Extracting a local lambda turns a block of code into an anonymous inline function.  Motivation A local lambda can isolate code for improvement (the Isolate-Improve-Inline pattern – see References), or...

View Article

Image may be NSFW.
Clik here to view.

Refactoring: Replace Method with Method Object

Sometimes, when you try to break up a long method, you run into a problem: you have to pass a bunch of local variables into the new method, some of which are both input and output. One solution is the...

View Article

Image may be NSFW.
Clik here to view.

A Dead End for Evolutionary Design

In traditional design, you identify the capabilities and characteristics of a planned system, then create an overall design that accommodates them. In evolutionary design, you grow the system one...

View Article
Browsing index pages (123 articles)


Latest Images