Do You know Mini Metro?
In short Mini Metro is a game with an amazingly simple interface which intrigued me so much that I bought the game. In this game, you are making metro lines that connect stations. Our high score is how much passengers traveled via our metro to their destination.
What it has to do with code?
While playing it, I had an epiphany. It is an excellent way to explain how lousy quality code comes to be!
Just look at this mess:
But it wasn’t like that from the beginning.
We started with three stations to connect. Simple, uncomplicated stuff yet even here we have few options. Do we do it using one line?
and in what configuration
But it is still easy. But as a game is coming we are getting more and more stations. And further away from the center.
Doesn’t it remind it of something? Yup new features in application new classes new functionality that developers had to add. Bugfixes, unexpected changes. That morphs beautiful design into the nightmare.
And with enough iterations of this, We get here.
But you can refactor your code.
Or even go full green field.
But IF you won’t do your research you won’t take a moment to plan what you want to do you can end with the solution as bad. But as with programming, some resources can help you:
Guides, best practices and even patterns (grids) which are also used in actual city planning.
This is the place I wanted initially to finish this article. With summary „so if you want to see how the legacy code is born. Play mini metro for a while.”
I lied – More thoughts
But the insight of actual transit planning expert http://humantransit.org/2014/12/learning-how-transit-works-from-mini-metro.html
Made me realize there are more comparisons here… Realy! Read his article! See for yourself how many parrels you can drow to software development. I will put bellow few of my favorite quotes bellow.
„Mini Metro imagines a city that is planned by someone else, or that grows haphazardly, where the transit system is totally reactive, A large area that’s all residential with few jobs (e.g., circles without squares) is a big problem that will quickly overload your network, no matter what you do.”
This Quote made me appreciate roles of software architect much more. It shows the importance of someone who has the vision of architecture and is looking into future. If the team is only reactive. It will end with lots of code that will have to be often rewritten in reaction to stakeholders new ideas. This itself if not the problem as long as we have an architecture that can support this kind of changes.
„As a result of the city getting larger, the network has not only grown but changed. Once other squares appeared, it was no longer necessary to run the whole network to the original central square. Instead, the demand pattern called for a grid, the ideal network structure for a city with balanced everywhere-to-everywhere demand.”
Outside of the mention of patterns. This shows how small product changes its role. Something that was once in the center of attention is no longer as crucial. For example, the user now can access some your product not only from the web but also via the phone app. And this requires a rethinking of architecture.
„Grids, I should add, aren’t always the answer. The game includes a couple of cities, notably Auckland and Osaka, where there are so many water barriers that the need to conserve tunnels imposes a dramatically different shape.”
There is something called pattern fiver. When developers try to use they favorite pattern even in places that are not required.
„Indeed, the essence of what’s fun about this game is that you have to keep revising your notion of what’s a good structure.”
This quote for me is close to explaining the nature of Agile.
Ergo experimentation and fast feedback and ever-changing nature.
„Buses are not flexible forever; well-designed networks do finally settle into successful patterns that become permanent, which means they could safely be converted to rail in the future.”
But at some point, you can’t change as cause there is no more need for such drastic changes and experiments.
Again, go read the article yourself. And check how many parrels you can draw. Remeber if you find something interesting, share it with me.
If you want to read more test inspirations check here.