Incremental Design with Standards-Based Products
Products supporting standards have an all-or-nothing flavor. After all, who wants a compiler for only half of a programming language? We’ll look at guidelines that let you develop such products...
View ArticleSemantics of FOR-NEXT Loops
I’ve been implementing the FOR-NEXT loop in a BASIC interpreter I’m building. It brings up some issues of programming language semantics. 10 FOR X = e1 TO e2 [STEP e3] 20 -- body 30 NEXT X...
View ArticleSwimming in a Rich Domain
Many domains are shallow and impoverished, e.g., apps that exist to write well-understood fields into a database. A rich domain has many concepts (some contradictory); it has lots of history; and it’s...
View ArticleA 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 ArticleRefactoring: 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 ArticleRefactoring: 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 ArticleIterative 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 ArticleReduce 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 ArticleOrganizing 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 ArticleRefactor: 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 ArticleTime 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 ArticleThreaded 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 ArticlePipelines – 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 ArticleTrees – 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 ArticleTDD 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 ArticleSwift 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 ArticleRun 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 ArticleAnd-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