DEV Community

Imamori Daichi
Imamori Daichi

Posted on

Introduction to Clean Architecture for TypeScript: PART1

Refs

What is Clean Architecture?

Clean Architecture is a software design methodology proposed by Robert C. Martin.
Looking back at its history, the Clean Architecture methodology was introduced by a blog post on August 13, 2012.
An English version of the book was published in 2017.


Robert C, Martin. "The Clean Architecture". Clean Architecture. Pearson Education.

Clean Architecture is a design methodology derived from Robert C. Martin's experience in various software (or hardware) developments.
The image is often used to represent Clean Architecture, and even if you don't know much about Clean Architecture, you've probably seen this diagram before.
The details of this diagram will be described later, but I introduced it at the beginning because it is an important diagram in explaining the Clean Architecture.
I hope you will keep this concentric circle diagram in mind as you continue reading.
The following sentence is from the preface of Clean Architecture.

The architecture rules are the same!
This is startling because the systems that I have built have all been so radically different.
 Why should such different systems all share similar rules of architecture?
 My conclusion is that the rules of software architecture are independent of every other variable.
(Robert C, Martin. "Preface". Clean Architecture. Pearson Education.)

These common rules for software development are summarized as practices and are called Clean Architecture.
In other words, Clean Architecture was born as a common rule by highly abstracting the experience gained from various developments.

Of course, extracting best practices from experience and compiling them into rules has been done before Clean Architecture.
The history of programming language paradigms is just that, and so are programming patterns such as the GoF design pattern.
There is also a collection of design principles called SOLID, compiled by Uncle Bob himself.

In "Clean Architecture", Sections I through IV will be used to explain these traditional practices.
In this way, Clean Architecture is a design methodology that draws on existing practices.
Therefore, Clean Architecture is not a design methodology that has been released in recent years, but rather it is based on empirical rules that have been developed by many software developers over the years.
On the other hand, there are some things to keep in mind.As mentioned earlier, Clean Architecture is a highly abstracted method.

Since it does not propose specific implementation methods, it cannot be directly applied to actual software development.
Therefore, it is necessary to understand the meaning of the abstraction of this design methodology and to put it into the concrete work of actual software development.
In some cases, you may want to apply some of the rules in Clean Architecture and ignore others.
However, even if you dare to ignore the rule, there is a big difference between knowing the rule and ignoring it, and breaking the rule without knowing it.
In these articles, we will grasp the principles of Clean Architecture and then discuss how to apply Clean Architecture when building React applications.

Why Clean Architecture?

In "Clean Architecture", the world realized by good software design is described as follows

The goal of software architecture is to minimize the human resources required to build and maintain the required system.
(Robert C, Martin. "What Is Design and Architecture?". Clean Architecture. Pearson Education.)

Leaving aside the question of how feasible this goal is, few developers would deny the goal itself.
Clean Architecture has been proposed as one of the means to achieve this goal.
As I said it is a means to an end, you can also aim for this goal by means other than Clean Architecture.
Of course, not everything will work with Clean Architecture.
The specific implementation is not within the scope of Clean Architecture, and adopting it does not immediately solve anything.
What Clean Architecture provides is the thinking and practices to achieve the above goals.
There is no solid right answer for the implementation to realize it, and there are as many right answers as there are products.

Learn about the background and concept of Clean Architecture, and we believe that cultivating the ability to think about how to apply it to specific implementations is necessary to achieve a step-change in software design.
In particular, it can be applied to React applications to empower not only web development but also application development on multiple platforms and it will support product growth.

Clean Architecture and Domain Driven Design

Domain Driven Design (DDD) is one of the building blocks of Clean Architecture.
DDD is a software design methodology proposed by Eric Evans.
DDD focuses on how to link business domains and software development, and does not refer to individual technologies.
What is important in DDD is that domain experts and software developers, who are familiar with the business domain, can communicate with each other through a common language, the ubiquitous language.
The point is that we shape our services through communication.
Clean Architecture is based on the concept of DDD. Domain models and domain logic, which are formed through communication, are the core and most important elements of a service.
Clean Architecture focuses on how to protect them from surrounding dependencies.

In this way, Clean Architecture is closely related to DDD and cannot be separated from it.
In the book "Clean Architecture", terms such as domain, domain model, and other terms used in DDD such as Entity and Repository also appear.

NEXT: Introduction to Clean Architecture for TypeScript: PART2.

Ads

This article is an excerpt from the first chapter of the book "React Clean Architecture". Some wording has been changed. You can buy the kindle version of this book from amazon.

React Clean Architecture

Top comments (0)