Asosiy tarkibga o'tish

Desegemented

Maqola yozilish jarayonida

Uning yaratilishini tezlashtirish uchun siz:


๐Ÿฐ 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