Plainionist Plainionic Programmer

Implementing Clean Architecture - Are Asp.Net controllers "Clean"?

How do Asp.Net Controllers fit into the context of Clean Architecture? Do they belong to the interface adapter layer?

In the previous post I have discussed controllers and presenters. I have shown you how I have implemented my controllers and presenters in the Athena project.

I was quite happy with my design so far but there was one thing which puzzled me …

In Asp.Net MVC a controller derives from System.Web.Mvc.Controller which creates a dependency from my controller to the Asp.Net framework. Taking the Dependency Rule strict that either means my design is invalid or my controller actually belongs to the “frameworks” circle.

In order to learn what others think about this design I have posted my question at StackOverflow and had a discussion with @herbertograca.

In this post I will share what I have learned and how I solved the puzzle …

Plainion.JekyllLint 1.1 released

New rules for SEO added!

JL0006

Images should have “alt” text. This is not only important in case the image cannot be displayed, it also impacts SEO.

JL0007

Images should have “title” text. This is not only serving as tool-tip, it also impacts SEO.

Blogging with Jekyll - My IBE

After having blogged with Jekyll for some while now I have found some convenient setup which makes me feel quite effective. Today I want to share my setup with you. Maybe some aspects inspire you, maybe you want to leave a comment about your own setup to inspire me?

Implementing Clean Architecture - Of controllers and presenters

From Clean Architectures circles lets take out the 'interface adapters' one and deep dive into controllers and presenters.

Last time we discussed about use cases and interactors and stopped with the question: “Which role is than actually left to the controller and presenter?”

In this post I will take this question up and dive deeper into the world of controllers and presenters in the context of the Clean Architecture.

Read on!

Plainion.GraphViz 2.9 released

ChangeLog

  • Size of the filter editor slightly increased to that all content fits without scrollbar
  • Added option to copy identifiers and captions of all visible nodes in a cluster to clipboard

Download now

Clean Architecture and Design

While preparing my next post on Implementing Clean Architecture I watched again Uncle Bobs famous talk on Clean Architecture and Design.

I know it is more than three years old but if you are interested in Clean Architecture you should take your time and watch it. Uncle Bob explains nicely - and a little bit funny as usual ;-) - what the Clean Architecture is about, how the puzzle is built up and why it has to be like this.

And as a summary for this video and as an outlook to my next post here is the key message:

The user interacts with the view. The view passes a request (defined in the interface adapter layer) to the controller which converts it into a request model defined in the use case layer. The interactor takes the request model though a input port and produces a response model which gets passed through an output port to the presenter. The presenter converts the response model into a response object defined in the interface adapters layer to the view. The view renders the response for the user

Simple things should be simple - complex things possible

Just recently I found this great article about Multiple levels of abstraction by Tomas Petricek. I know the article is already a bit older but everything it talks about is very valid still.

The key message is this:

  • A library should expose its functionality as multiple layers of abstraction.
  • At the highest level, 80% of the scenarios can be handled with a single function call.
  • The next 15% can be implemented with a little more work and some lower level functions.
  • The next 4% are the rare cases which require usage of the lowest level APIs.
  • For the last 1%, you have to send a pull request!

Tomas continues giving three great examples to illustrate his point.

The article is very worth reading and we should keep the presented principle in mind when designing libraries.

An Introduction To Clean Architecture

Today I found a nice article on the NDepend Blog: An Introduction To Clean Architecture.

The post gives a nice introduction by first motivating clean architecture by looking at the short comings of the traditional layered approach. It then gives some history about the Clean Architecture. Finally the post briefly introduces the Clean Architecture itself - the circles and the dependency rule.

It was a nice read - looking forward to read the follow-ups.

Implementing Clean Architecture - What is a use case?

From Clean Architectures circles lets take out the 'use cases' one and deep dive into it.

Now that my architecture is screaming the business capabilities of my system let’s look at those with more detail.

In the Clean Architecture all the application specific business rules go into the use cases circle.

But what is a use case? How big should it be? How does it interact with its environment?

Read on!

Plainion.GraphViz 2.8 released

ChangeLog

  • Online help is included as markdown in the released package
  • Various UI tooltips improved
  • Zoom slider added
  • Zoom with cursor keys at mouse position supported
  • Bookmarks added to enable jumping between different settings

Implementing Clean Architecture - Make it scream

How do I make my architecture “scream”?

According to Uncle Bob an architecture “screams” when it clearly expresses its core business purpose. The top level folder structure, the project/DLL names and the namespaces should express business aspects rather than frameworks or other details.

Athena is a web application implemented in ASP.NET MVC. But is this important? I could switch to Ruby on Rails or Node.js - it wouldn’t make any difference for the business. Why do we let such details impact our project structure so often?

Implementing Clean Architecture - An Overview

Let’s briefly summarize what the Clean Architecture is …

The Clean Architecture consists of multiple layers organized as circles while dependencies are only allowed from outer circles to inner circles. The inner circles contain the business logic. All details, devices and frameworks are in the outer circles.

How to implement the Clean Architecture?

Did you enjoy reading Uncle Bob’s Clean Architecture?

Book: Clean Architecture

I did! As with every book from Uncle Bob’s it is motivating and inspiring, right?

So let’s take his ideas and realize these in our projects to gain what he is promising!

But how do I start? How do I transform an existing code base - following a layered (web) architecture - into the Clean Architecture?

The Clean Architecture consists of multiple layers organized as circles while dependencies are only allowed from outer circles to inner circles. The inner circles contain the business logic. All details, devices and frameworks are in the outer circles.

Death by Powerpoint

Are you scared of doing presentations? Especially in front of a bigger audience? You don’t have to! Just don’t do these mistakes …

  1. Using corporate templates
  2. Having content packed slides
  3. Writing full sentences
  4. Focusing on the slides during presentation

Blogging with Jekyll - SEO

Are you missing readers on your blog? Don’t make this mistake …

… and forget about SEO!