Skip to content

Commit

Permalink
Merge pull request #142 from emacsway/emacsway
Browse files Browse the repository at this point in the history
Emacsway
  • Loading branch information
emacsway authored Jan 21, 2024
2 parents 57d3e08 + 2e2fa52 commit 0ca97ec
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions emacsway/it/ddd/grade/domain/aggregate-encapsulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,15 @@ Exporter
Это еще один аргумент в пользу первого варианта с отдельными сеттерами для каждого атрибута Агрегата.

Попробовав оба варианта, я остановился, все-таки, на первом, каноническом, даже несмотря на его многословность.


Импорт состояния
================

В Golang область видимости структуры доступна всему пакету, поэтому нет большой необходимости реализовывать Importer/Provider - достаточно положить Reconstitutor в тот же пакет.

В других языках может потребоваться делать Importer/Provider, что образует брешь в инкапсуляции.
Поэтому импорт состояния делают либо посредством конструктора, если поддерживается множественная диспетчеризация (overloading), либо посредством статического метода класса - чтобы можно было создать, но невозможно было изменить.
Правда, при этом возникает сложность с синхронизацией состояния объектов в IdentityMap при фиксации изменений (commit), ведь состояние агрегата теперь недоступно для синхронизации.
В таком случае остается только очистить IdentityMap при фиксации изменений.

4 changes: 4 additions & 0 deletions emacsway/it/ddd/grade/domain/shotgun-surgery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Shotgun Surgery
===============

Может показаться, что используя Raw-SQL мы обретаем классифицированный Code Smell, известный как Shotgun Surgery (Разлет Дроби), ибо добавление одного поля в Сущность требует правки многих файлов.

Это не так страшно, т.к. :ref:`ввод символов с клавиатуры не оказывает существенного влияния на темпы разработки <emacsway-who-reads-the-code>`, поскольку занимает не более 10% от времени конструирования кода.
При этом вероятность возникновения ошибки тоже минимальна, т.к. легко отлавливается статическим анализатором кода.

Есть два способа решить эту проблему (и снизить Coupling), о которых писал Martin Fowler в главе "Metadata Mapping" книги "Patterns of Enterprise Application Architecture": "reflective program" и "code generation", причем, сам он лично предпочитает второй вариант:

Generated code is more explicit so you can see what's going on in the debugger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ Repository and Causal Consistency
И здесь обнажается проблема, т.к. при инкрементировании версии агрегата единожды на транзакцию, возникает риск образования более одного публичного Доменного События с одной и той же версией Агрегата.
А это означает, что версию Агрегата не получится использовать для восстановления очередности Событий.

Есть еще одна проблема.
Если за один инкремент версии агрегат издал несколько событий, то при обновлении ReadModel по событиям её версия разъедется с версией агрегата, и будет утрачена возможность отслеживать, например, с frontend, докатились ли изменения до ReadModel.
Но это так же означает, что доменное событие должно производиться на абсолютно каждое изменение состояния агрегата.


Варианты решений
================
Expand Down
7 changes: 7 additions & 0 deletions emacsway/it/sdlc/models/agile/agile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,13 @@ Impossible. Точка.

-- "Software Architecture in Practice" 3d edition by Len Bass, Paul Clements, Rick Kazman

..
💬 So, agile and architecture are addressing the same problem from different angles: architecture gives you the options to sustain velocity when the unexpected happens.
And agile gives you the attitude to always be learning and to quickly adapt to changing circumstances.

-- "`Agile and Architecture: Friend, not Foe: Agile methods and architecture both thrive in times of uncertainty. <https://architectelevator.com/transformation/agile_architecture/>`__" by Gregor Hohpe

..
💬 "After all software is supposed to be soft."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ Simon Brown тоже обратил внимание на тот факт, чт

💬 "Architecture is the decisions that you wish you could get right early in a project, but that you are not necessarily more likely to get them right than any other." -- Ralph Johnson

..
Remember Johnson’s secondary definition: “Architecture is the decisions that you wish you could get right early in a project.”
Why do people feel the need to get some things right early in the project?
The answer, of course, is because they perceive those things as hard to change.

-- "`Who Needs Architect <https://martinfowler.com/ieeeSoftware/whoNeedsArchitect.pdf>`__" by Martin Fowler

на

💬 "A good architect pretends that the decision has not been made, and shapes the system such that those decisions can still be deferred or changed for as long as possible.
Expand Down
1 change: 1 addition & 0 deletions emacsway/soft-skills/cognitive-biases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@

- "`Логическая ошибка <https://ru.wikipedia.org/wiki/%D0%9B%D0%BE%D0%B3%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D0%BE%D1%88%D0%B8%D0%B1%D0%BA%D0%B0>`__"
- "`Список когнитивных искажений <https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%BA%D0%BE%D0%B3%D0%BD%D0%B8%D1%82%D0%B8%D0%B2%D0%BD%D1%8B%D1%85_%D0%B8%D1%81%D0%BA%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B9>`__"
- "`Демагогические приемы <https://ru.wikipedia.org/wiki/%D0%94%D0%B5%D0%BC%D0%B0%D0%B3%D0%BE%D0%B3%D0%B8%D1%8F#%D0%9E%D1%88%D0%B8%D0%B1%D0%BE%D1%87%D0%BD%D1%8B%D0%B5_%D1%81%D0%B8%D0%BB%D0%BB%D0%BE%D0%B3%D0%B8%D0%B7%D0%BC%D1%8B>`__"
- "`Decision-making <https://en.wikipedia.org/wiki/Decision-making>`__"

- "`5 cognitive bias examples and how to avoid them in decision-making <https://www.atlassian.com/blog/productivity/cognitive-bias-examples>`__" by Ben Crothers
Expand Down

0 comments on commit 0ca97ec

Please sign in to comment.