Learning The Clean Architecture and Applying it While Doing BDDThe Clean Architecture
Uncle Bob Martin's Clean Architecture is one that I am aspiring to model my applications and Services by currently.
I realized that after thinking about it, when I was pairing with a couple 8th light guys in the past at a previous company, that they were implementing some of the Clean Architecture in our Web Service code. At the time, I was not aware of the Clean Architecture Model (Onion). I was defintely aware of creating layers and did create layers such as Repository, Business Objects, and all that.
But I realized that how I was doing that prior, wasn't quite clean.
So I am suggesting that if you really wanna build your architecture in a very simple and decoupled manor, I'm advocating The Clean Architecture model. It very much mirrors the Hexagonal Architecture Model.
So if you would like to venture off learning more about it, then I suggest going about it in a certain fashion, and to go through these resources in a specific order below. This order really helped me understand Applying the Clean Architecture (patterns, layers, etc.) along with incorporating that while you TDD the actual implementation.
Here's the order I suggest (my prescription). There is specific content in here that piggies on one another.
Make these worth your while:
- Set aside true quiet time away from kids or whatever..in your man cave if you have one
- Watch each video in full. Yes unfortunately this takes time and dedication. Take a Saturday to do it, do it at night for 2-3 hours;...whatever you have to do to find time to watch each of these in full. If you wanna learn, you gotta sacrifice. But these resources are truly great ones below, you won't be sorry
- Concentrate. Listen to everything said very carefully, and definitely take notes..I always go back to my notes, I don't wanna re-watch it 100 times because I forgot everything
- It'll take you weeks to get through all these but seriously watch them all, again the order here is important
First, Understand Clean Architecture
- Start with reading the blog post by Uncle Bob: The Clean Architecture
- Then watch Clean Code → Episode 7, Architecture, Use Cases, and High Level Design and understand it well. Take your time on this, play it a couple times if you have to. This video is critical, don't stop in the middle, watch it all the way as will get you into the nitty gritty details and nobody explains it as well as Uncle Bob himself
- The watch Decoupling from ASP.NET - Hexagonal Architectures in .NET - nevermind that this is titled .NET, Ian keeps things applicable and terms are not really geared toward .NET so this is a good watch for anyone .NET or not
- A deep dive into truly understanding Hexagonal. And Ian explains it like no other
- Then watch Rails Conf 2012 Keynote: Simplicity Matters by Rich Hickey
- Then watch Keynote: 8 Lines of Code - which talks about how you really keep code simple, and the fact that you do not need to always use frameworks which can actually make things more complicated or totally unnecessary if you design your code in very small modulars. (BTW, This is also is a big reason why I left .NET. Microsoft pushes shitty frameworks, horrible xml driven frameworks, and more garbage down your throat when you just need simple, clean, decoupled code which means you end up not needing all those heavy frameworks Microsoft tries to push down your throat)
- Then read Corey Haines's book 4 Rules of Simple Design
Finally Get into the BDD
This will apply some of what you learned above to actual code.
After you've watched and read the previous section, now is the time to understand proper BDD and applying the concepts above.
- First, Understand what Good Unit Tests are by watching Unit Testing Best Practices with Roy Osherove
- Then watch Roy Osherove's Understanding Test Driven Development
- Then watch Ian Cooper: TDD, where did it all go wrong which will get you into proper TDD principals and a bit of the Hexagonal architecture concepts
- Then read Ian Cooper's Blog Post: Avoid Testing Implementation Details, Test Behaviours which is a good read right after, that nicely summarizes some of his Where did TDD go wrong video
- Then read TDD, avoid testing implementation details which I thought was a really nice post by some dude just genaralizing this issue
- Then watch at the least, the first two videos of the Corey Haines TDD Series - Build an App with Corey Haines
- Then watch Java Case Study → Episode 1, Getting Nothing Done because now that you have all the above in your head, you can learn how to BDD while keeping clean architecture in mind and how to partition your system that way. Get into the heads of seasoned BDD developers here from 8th Light including Uncle Bob himself on a real Application. Watch carefully at each line of code they write. Think about how they're approaching the code at first. Think about where the interactors are, what the gateways are doing, and pay close attention to what they say. And TBH, you'll want to watch this a couple times
- Then watch Java Case Study → Episode 2, Let the Testing Begin - Part 2
- Then sign up and pay for The World's Best Intro to TDD Course by J. B. Rainsberger..his price is more than reasonable and affordable for his course for any individual out there
Optional but a good Resource for later when you have time after all the above: Start Doing Real World TDD Now!. This blog is by Eric Smith. He's a developer I had the privilege to pair program a bit from 8th light, and he runs their training program at 8th Light, their Apprentice program.
I probably learned more in 5 months with Eric and another 8th Light Consultant that would have taken me 2 years to learn. Honestly while the list above is awesome, the best way to learn BDD IMO is to pair with seasoned TDD'ists. Get 8th Light to come into your company for a few months, year, whatever. The benefits are exponential for your team and your company as I have experienced myself with these guys.
Yes this is a lot to read up on and watch but I guarantee it'll help bridge the gap much sooner.
Hoping this helps others as it has helped me bridge the gap with Clean Architecture, Hexagonal, Ports, Adapters, and how to approach this and separate this while doing test driven.