“Does choosing the Given-When-Then approach vs. Arrange-Act-Assert make us think differently?”

I’ve been pondering languages a lot over the years, both spoken and programming languages. My observations are based on my experience as a multilingual individual who has programmed in a few different languages for the last 30 years.

The spoken language I choose to communicate does affect how I think.

I drove to work on a particular day, knowing I’d have a sprint review early in the morning. As I drive, my mind has thoughts about the flow of the conversation (e.g., “How do we better convey the value we’ve produced in this sprint? What is the best story arc to demonstrate the results?”). I know everyone in the room speaks English, the language of the upcoming conversations. So, my mind thinks in English and tries to problem-solve in that language. That’s the perspective.

That afternoon, I drove home. I knew my wife would ask me how my day went. We only speak Portuguese at home, so I think in Portuguese as I drive. That’s the perspective.

Looking at a problem from different perspectives makes me think differently.

I’ve noticed similar thoughts when using a programming language to solve problems. For example, if I’m writing code in C#, my initial inclination is to think object-oriented. But sometimes I look at it and ask: “How would I write this in Ruby? Hmm, that’d be similar to how I solved some problems dynamically in FoxPro. Would that be a valid approach in C#?”

Thinking in different languages gives me different perspectives when problem-solving.

Back to GWT and AAA. If I’m presented with…

// Arrange

// Act

// Assert

…my mind immediately wants to fill in the details, thinking in technical terms constrained by the programming language:

// Arrange
//...instantiate some classes
//...set some properties
// Act
//...instantiate a system under test (sut)
//...call a method on it...
// Then
// ...verify some properties
// ...verify object interactions

Stepping back from the nitty-gritty technical details and focusing on the problem at hand can be a relief. It’s a common pitfall for us developers to get so engrossed in the system and its implementation that we lose sight of the problem that needs solving.

Instead, if I’m presented with…

Given...
When...
Then...

…I’m focused on a desired behavior. This approach makes it easier to avoid getting bogged down in technical concerns.

Granted, those statements could still be written to describe technical concerns, but I’ve trained not to do that and isolate behavior from the system under test.

This simple shift of language (Given-When-Then vs. Arrange-Act-Assert) shapes how I think about solving problems and helps me stay focused.

Research

Shortly after starting to write this blog post, I found several videos that explain this topic and the research that goes into it. Here are some of them:

Leave a Reply

Trending

Discover more from Claudio Lassala's Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading