Clean Architecture with Xamarin Forms

Clean Architecture with Xamarin Forms
Photo by Lance Anderson on Unsplash

Delivering quality software is a big deal these days.

The quality, good or bad - of a software solution has significant impacts on the developers who make it, the companies employing them, and, most importantly, the users who rely on it to provide some value in their daily lives — quality matters.

How is Software Quality Measured?

There are all sorts of things like test coverage metrics, code analysis tools, performance benchmarks, SLAs, and on and on that can be used in an attempt to quantify the quality of a software product.

The value in each of those is debatable and varies wildly when applied to the unique requirements, technologies, methodologies, and environments that must be combined to produce software. Each team and project are different, with their very own DNA, which makes them hard to compare.

There are, however, a few practical and consistent attributes we can use when discussing quality, and they apply to just about any application.

Deployment - How quickly can the software be built and deployed? How much friction or manual intervention is involved?

Testing - Can you test important logic quickly and easily using a suite of automated unit tests? Is unit testing constrained by things like databases, network connections, or user interfaces required to make the code run?

Maintainability - As requirements are added or changed over time, can developers refactor or extend the code with the confidence they haven't broken working functionality while trying to implement something new?

The answers to these questions can help highlight areas in which we might be experiencing quality issues. And when combined, provide some useful input to at least start the quality discussion.

Get notified on new posts

Straight from me, no spam, no bullshit. Frequent, helpful, email-only content.

Where Does Quality Start?

In many instances, I would argue the quality of a software project, good or bad, is mostly set in motion before the first line of code is cut. During the architecture and design phase, when boxes and lines are drawn on whiteboards representing the components, interactions, and assumptions we believe will satisfy the requirements.

When you break it down at this point in the process, how all these things get stitched together with code ends up having a significant impact down the road on the critical areas listed above.

The Clean Architecture

With the belief that good software starts with good architecture, Uncle Bob introduced the programming world to The Clean Architecture way back in 2012 followed by a book a few years later.

Some key characteristics and benefits of The Clean Architecture are:

No Dependency on Frameworks

The architecture does not depend on the existence of any specific software library or technology. That means using frameworks as tools instead of having to make your code work within their opinions and constraints.

Testability

We can test the business rules without a UI, database, web server, or any other external dependency.

UI Agnostic

We can easily change the UI without changing the rest of the code. We can hook up the business rules to a modern SPA application in the browser or a mobile app, as we'll see in this guide. It doesn't matter; we can replace the interface without impacting the business rules.

Database Agnostic

Do you use a relational database like Sql Server or MySQL? Maybe you're using document-based storage with Mongo or CouchDB - or even a combination of these. Similar to the UI, it doesn't matter because, in Clean Architecture, there is no binding between the business rules and database.

Independent of Any External Dependency

The business rules don't know anything at all about the outside world.

This principle is the essence of Clean Architecture.

Xamarin.Forms and Clean Architecture

In this post, we'll design and build a Xamarin.Forms mobile app using some of the fundamental principles and ideas found in The Clean Architecture.

**** MORE HERE PLZ ****

Get notified on new posts

Straight from me, no spam, no bullshit. Frequent, helpful, email-only content.

Related Posts


Better Software Design with Clean Architecture
Better Software Design with Clean Architecture

Jun 30, 2017

Read more
Building ASP.NET Core Web APIs with Clean Architecture
Building ASP.NET Core Web APIs with Clean Architecture

Sep 30, 2018

Read more
Get notified on new posts
X

Straight from me, no spam, no bullshit. Frequent, helpful, email-only content.