Yoan THIRION (freelance) • design software since more than 15 years • fundamental to succeed in that area : agility and technical excellence • help teams deliver well crafted software • implementation of agile and technical practices (eXtreme programming, Refactoring, DDD, Mob programming, …) Let’s connect My services https://www.yoan-thirion.com/ Technical agile coaching Communities of practice Cultural change devops Brown bags Serious games
business logic) and test automatically its behavior independently of other concerns (Database, Services, …) class Program { static void Main(string[] args) { // 1. Instantiate right-side adapter(s) ("I want to go outside the hexagon") IObtainPoems fileAdapter = new PoetryLibraryFileAdapter(@".\Rimbaud.txt"); // 2. Instantiate the hexagon IRequestVerses poetryReader = new PoetryReader(fileAdapter); // 3. Instantiate the left-side adapter(s) ("I want ask/to go inside the hexagon") var consoleAdapter = new ConsoleAdapter(poetryReader); System.Console.WriteLine("Here is some..."); consoleAdapter.Ask(); System.Console.WriteLine("Type enter to exit..."); System.Console.ReadLine(); } }
the Onion, there is a strong dependency rule outer layers can depend on lower layers, but no code in the lower layer can depend directly on any code in the outer layer. Dependency Inversion Principle for the architecture
of libraries Allow us to use frameworks as tools (not a constraint) Independent of the front-end Can easily change the UI (from web to console) Independent of the database Business rules not bound to Database logic Independent of any external agency Business rules don’t know anything about outside world What characteristics do these architectures have in common?
§ from the format most convenient for the use cases and entities, § to the format most convenient for some external agency such as the Database or the Web • In a MVC architecture : o Presenters, Views, and Controllers
o Database o Web Framework Glue code that communicates to the next circle inwards. • This layer is where all the details go o Keep these things on the outside where they can do little harm.
concepts behind clean architecture The features of the application are basic crud : • Create a user • Find a user • List all users • Login a user with their password
know why, but people tend to mess up splitting responsibilities between layers, especially harming the domain model • Indirection – interfaces everywhere! • Potentially heavy • Plays well with DDD – architecture that builds everything on top of a domain model • Directed coupling – the most important code in our application depends on nothing, everything depends on it • Flexibility – from an inner-layer perspective, you can swap out anything in any of the outer layers and things should work just fine • Testability – since your application core does not depend on anything else, it can be easily and quickly tested in isolation
you can be sure the same inputs will give the same outputs. Pure functions don’t refer to any global state. The same inputs will always get the same output. let Double i = i * 2