Wrapping a Type, All the Way
Sometimes you want to change from using a basic type (such as Int or String) to a type that contains the basic type as a value. (See Refactoring in the References.) The change itself isn’t hard, but...
View ArticleNested Loops to Functional Pipeline
Nested structures are challenging to read; a pipeline is usually easier to read and think about. Nested structures have that “arrow of doom” feeling, where you work your way in multiple levels then...
View ArticleRefactoring: Forcing the Right Extract Method
Automated refactoring tools are great, but sometimes the tool doesn’t make the best choice. We can often nudge the tool to a better choice. Why Bother? Why bother nudging? Couldn’t you do the...
View ArticleUser Stories and Quality Attributes
Conversations about user stories focus on the behavior of a system, without regard for time, memory, etc. Other times, we have real-world constraints – quality attributes – that may not fit...
View ArticleExtracting Parameterized Unit Tests
Duplication across tests may not be as harmful as duplication in production code, but a parameterized unit test can reduce duplication and help us create better tests. Judging Tests – The Pause...
View ArticleExample Parameterized Tests: Java, Kotlin, and Swift
Last time (“Extracting” in References), we looked at why you’d use parameterized tests, to reduce duplication, improve clarity, and improve test quality. This time we’ll look at an example...
View ArticleWhat Is a User Story?
A user story is a scenario, a description of a (potential) real use of a system. It takes thae customer or user perspective, and represents a team’s shared understanding of what the system should do....
View ArticleLambda for Control Structures, a Refactoring
Several mainstream languages have added better support for lambda expressions (including lighter syntax) in the last few years. This can let you define new forms of control structures, and reduce...
View ArticleLambda to Reduce Coupling
Coupling occurs when one part of a system depends on another part. That is, if one part changes, the other must be adjusted too. Lambda expressions can reduce coupling by needing to refer to fewer...
View ArticleRefactoring and Programming Language Semantics
Refactoring improves the design of code without changing its observable behavior. But what is observable behavior? We’ll look at how language semantics affect that. When you devise new refactorings,...
View ArticleQueues from Stacks: Functional Data Types
Functional languages often have immutable data types – you can’t change an object once you’ve created it, though you can include it as part of other objects. Immutable objects are easier to reason...
View ArticleLoop Unrolling: While ⇒ If-While
Loop unrolling is a performance optimization where you repeat the inside of a loop to reduce the looping overhead. It’s also a way to get rid of loops, and we’ll look at an example from a test. While...
View ArticleIntensifying Stories with Limited Input
I recall a game design challenge where your only input is a pushbutton. What if your only input is a single textfield? Let’s look at what search engines have done under this limitation. That can give...
View ArticleImmutable Objects
Immutability is the idea that once created, data never changes. Why might we want this? Avoid aliasing bugs: Aliasing occurs when there are multiple ways to access the same piece of data, and one...
View Article2021 Articles in Review
Here are the the articles and videos I made last year. Key topics: user stories, refactoring, TDD, functional languages, and design. I’ve grouped them into these areas: User...
View ArticleSpooky Action at a Distance: Exceptions
How should we handle error conditions? We’ll look at the try-catch exception mechanism that’s similar across many languages, and a few patterns and pitfalls for working with it. Old-School One way of...
View ArticleTesting Exceptions: Harder Than It Looks
Exceptions are one of the most complicated constructs in many languages. Because of that, testing exceptions is one of the harder tests to do. Consider the following code. Assume block1 through block3...
View ArticleCassandra Teams
In Greek mythology, Cassandra was cursed: her prophecies would be right, but nobody would believe her. Unfortunately, software teams are sometimes in the same position: they identify an upcoming...
View ArticleTypealias for TDD
There’s a tension when you introduce new objects: type checking can help, but it often gets in the way while you’re exploring. If your language supports it, typealias can smooth the transition from...
View ArticleTDD with Recursion
Recursion means you define something in terms of itself. Some data fits naturally with recursion, e.g., trees. We’ll look at how to use TDD with recursion. We’ll use a tree for our running example. A...
View Article