Skip to main content

Desegemented

WIP

The article is in the process of writing

To bring the release of the article closer, you can:


🍰 Stay tuned!

Situation

Very often, there is a situation on projects when modules related to a specific domain from the subject area are unnecessarily desegmented and scattered around the project

β”œβ”€β”€ components/
| β”œβ”€β”€ DeliveryCard
| β”œβ”€β”€ DeliveryChoice
| β”œβ”€β”€ RegionSelect
| β”œβ”€β”€ UserAvatar
β”œβ”€β”€ actions/
| β”œβ”€β”€ delivery.js
| β”œβ”€β”€ region.js
| β”œβ”€β”€ user.js
β”œβ”€β”€ epics/
| β”œβ”€β”€ delivery.js
| β”œβ”€β”€ region.js
| β”œβ”€β”€ user.js
β”œβ”€β”€ constants/
| β”œβ”€β”€ delivery.js
| β”œβ”€β”€ region.js
| β”œβ”€β”€ user.js
β”œβ”€β”€ helpers/
| β”œβ”€β”€ delivery.js
| β”œβ”€β”€ region.js
| β”œβ”€β”€ user.js
β”œβ”€β”€ entities/
| β”œβ”€β”€ delivery/
| | β”œβ”€β”€ getters.js
| | β”œβ”€β”€ selectors.js
| β”œβ”€β”€ region/
| β”œβ”€β”€ user/

Problem

The problem manifests itself at least in violation of the principle of * High Cohesion** and excessive stretching * of the axis of changes**

If you ignore it

  • If necessary, touch on the logic, for example, delivery - we will have to keep in mind that it lies in several places and touch on several places in the code-which unnecessarily stretches our * * Axis of changes**
  • If we need to study the logic of the user, we will have to go through the whole project to study in detail * * actions, epics, constants, entities, components** - instead of it lying in one place
  • Implicit connections and the uncontrollability of a growing subject area
  • With this approach, the eye is very often blurred and you may not notice how we "create constants for the sake of constants", creating a dump in the corresponding project directory

Solution

Place all modules related to a specific domain/user case - directly next to each other

So that when studying a particular module, all its components lie side by side, and are not scattered around the project

It also increases the discoverability and clarity of the code base and the relationships between modules

- β”œβ”€β”€ components/
- | β”œβ”€β”€ DeliveryCard
- | β”œβ”€β”€ DeliveryChoice
- | β”œβ”€β”€ RegionSelect
- | β”œβ”€β”€ UserAvatar
- β”œβ”€β”€ actions/
- | β”œβ”€β”€ delivery.js
- | β”œβ”€β”€ region.js
- | β”œβ”€β”€ user.js
- β”œβ”€β”€ epics/{...}
- β”œβ”€β”€ constants/{...}
- β”œβ”€β”€ helpers/{...}
β”œβ”€β”€ entities/
| β”œβ”€β”€ delivery/
+ | | β”œβ”€β”€ ui/ # ~ components/
+ | | | β”œβ”€β”€ card.js
+ | | | β”œβ”€β”€ choice.js
+ | | β”œβ”€β”€ model/
+ | | | β”œβ”€β”€ actions.js
+ | | | β”œβ”€β”€ constants.js
+ | | | β”œβ”€β”€ epics.js
+ | | | β”œβ”€β”€ getters.js
+ | | | β”œβ”€β”€ selectors.js
+ | | β”œβ”€β”€ lib/ # ~ helpers
| β”œβ”€β”€ region/
| β”œβ”€β”€ user/

See also