DEV Community

Cover image for A beginners explanation of the Chicago & London approaches
Hibo Abdilaahi
Hibo Abdilaahi

Posted on • Updated on

A beginners explanation of the Chicago & London approaches

Author clarification: It has since been revealed to me that the Chicago school of thought is actually called the Detroit school. Please use this term for any future references.

I recently received feedback from a code review that my TDD approach may benefit from using the London school of thought approach vs. the Chicago school of thought approach. And my initial reaction was one of confusion...

There are different methods to approaching TDD tests? And what are the Chicago and London school approaches?

So, I decided to research these approaches over the weekend and share what I understood in case it is helpful for anyone out there.

Let’s start with the Chicago approach.

Chicago School of Thought TDD (Inside Out/Bottom Up/Classic)

This approach starts at the unit testing level and allows the developer to focus on one thing at a time. In particular, it focuses on filling in the detail for a particular feature, before moving onto the next.

An example of this approach came to mind when I was building a bowling scorecard program a couple weeks back.

I approached this project by testing and building a 'Game' class that focused on keeping track of the game (i.e. the frame and rolls a player was on, the game ending etc...) and then I moved onto testing and building the 'Scorecard' class that would calculate the score.

After all the unit testing was done, I moved onto feature testing and building the front-end interface where this information would be displayed to the player and ultimately where the player would play the game.

This is a Chicago approach to building the program as:

  • It focuses on building the program from the component/class level level upwards.
  • It focuses on state based testing, seeing through the testing of one class and its behaviour at a time.

London School of Thought TDD (Outside In /Top Down/ Mockist)

You might have guessed this but the London School of Thought is essentially the opposite of the Chicago approach.

This approach starts at the outer, feature layer of the program and slowly moves into testing the centre layer of the program (i.e. the unit tests for the components).

So rethinking my approach to the bowling scorecard program, I would start with feature tests, planning how the interface would look to the user and how the user would interact with it before moving onto the unit tests.

And admittedly, this is a little weird to me. Why would you start implementing feature tests without having any of the components you would need to create it (i.e. the game and scorecard objects)?

Well this is where mocking comes in which is a more crucial part of the London based approach (but still can be used in both!).

Let’s say my page would display the frame and roll the player was on, as well as the current score. In order to test that this information is displayed, I would need to mock the classes and return some test data that I would feature test is displayed on the web page.

For example, let’s say the page starts with a frame of 1, roll of 1 and score of 0. The player then rolls a 5 and I would want my web page to display that they are on their next roll with a score of 5. (i.e. Frame: 1, Roll: 2, Score: 5). And this is what I would feature test using mocks and stubs to return the fake data in place of the real data that I would receive had I implemented the classes and methods beforehand.

Once that feature test is done, I can unit test scorecard and game classes to replace those mocks and return real data.

The London School approach:

  • focuses on building the program from the outside, feature level moving into the inner level.
  • leaves the actual implementation of the classes until last

Ending remarks

I hope this article was useful to get an introduction to Chicago and London approaches to TDD. There is a lot that I haven’t mentioned here to keep it as simple as possible (and also as I'm still learning about the approaches), but I will leave some resources that I found useful along the way if you are interested in learning more:

Top comments (7)

n_develop profile image
Lars Richter

To be honest, I doubt that the creators named their practices "London School" or "Detroit School" themselves. Other people were looking for a name to distinguish between them and they just used the Cities they were "invented" (or maybe better "rediscovered") them.
I think "Outside-In" (London School) and "Inside-Out" (Detroit School) are pretty good names for it. Maybe not perfect, but better.

djsullenbarger profile image
David Sullenbarger

seems too academic for my senses

I'm probably going to get the back-end wired together pretty solidly so I know it's features and limitations well (so Chicago i guess) then start designing from the front (now London i guess?). The middle is fudge-able and mock-able or whatever (do it on your own machine for a while type stuff).

All without labeling (or even acknowledging) any of the individual approaches. Being forced into choosing one or the other would be very annoying and counter productive for everyone but the PM's office.

hiboabd profile image
Hibo Abdilaahi • Edited

I totally agree. I don't think it makes a difference either way as long as you test both the back and front end.

I would personally much rather focus on having the back end tested and working perfectly before moving to the front end. I guess that means I will following Chicago style but it's due to my preferences than any conscious effort to follow one school of thought or a belief that one is better than the other.

n_develop profile image
Lars Richter

Nice post. Thanks for putting it together. Even though some people get tired of TDD posts, I think it is an important topic that should be discussed much more.

Just a little side note: The "Chicago School" should really be "Detroit School". Just like in the second resource you named. I know that the name "Chicago School" is pretty popular, but there is no connection to Chicago. It was called "Detroit School" because it came out of Chryslers C3 project where Kent Beck and Ron Jeffries used it.

hiboabd profile image
Hibo Abdilaahi

I really appreciate the feedback thanks! I hadn't really considered researching TDD as a field until the feedback I received on my approach and I'm interested in learning lots more now. It's definitely an important topic and one that has more to it than meets the eye I feel...

Thanks for clarifying on the Detroit school. Being a Londoner I wasn't sure if Detroit was perhaps a city in Chicago and maybe they both meant the same thing? I will add a note to the top of the article stating that Detroit is actually the name of the school.

hiboabd profile image
Hibo Abdilaahi

Hahaha right?! This is the main takeaway from all this research

hiboabd profile image
Hibo Abdilaahi

Now what's left is to start a petition to get the names changed for everyone's benefit 😉