Thursday, June 18, 2015

SOLID Architecture in Slices not Layers by Jimmy Bogard

I have been a long time reader of Jimmy Bogards blog posts at Los Techies so it feels kind of awesome to see him live.

The seminar begins with a case study of a real world scenario that had become horribly complex. This leads into a discussion about the recommended n-tier structure of a system where everything is organized in layers.

By developing independent layers you run the risk of over-engineer the layers interface to ensure that the next layer has all the access points it needs. By slicing vertically through the layers and finishing each feature through all layers the interfaces area of each layer becomes exactly as big as it needs to be.

To create good separations Mr. Bogard suggest using the CQRS pattern and equates how this is similar to POST and GET for the web. To demonstrate this he digs into Microsofts ContosoUniversity example which he has re-done and is available on GitHub.

For modeling request a structure where input goes into a request handler which in turn produces output. To model these request Mr. Bogard have written a tool called MediatR which is also available on GitHub. This tool is also useful for constructing commands.

A new structure for structuring the project files is suggested where features a grouped together. Here it is suggested to create a class for the specific feature and internal classes for all needed components for that features, like commands, validators, and similar. I’m a strong believer of putting classes in their own files so I’m not so keen on this advice.

Jimmy Bogard does not take the normal approach of explaining SOLID principles where each principle is discussed separate whit a small example. Instead he dives into talking about architectural design decision with little to no reference to the SOLID principles. The actuall references comes at the end where all the architectual decisions are tied to the principles. This was a very nice way of handling SOLID.

No comments:

Post a Comment