v2.0.0 #701
idugalic
announced in
Announcements
v2.0.0
#701
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
v2.0.0
of the library is introducing breaking changes. Check the PR!To keep it simple,
v2.*.*
will use the main branch. Old version - v1.. will continue to be supported (bugs only, no new features)Besides keeping the focus on separating data from behavior, we want to split the responsibilities between the domain and application/adapter layers better.
Application layer components (Aggregate, MaterializedView, SagaManager)
CM
/CommandMetadata,EM
/Event Metadata) on the application layer. Observe how these types (CM
,EM
) are not leaking into the domain components, as these don't benefit core logic, for example:traceId
,correlationId
, ...optimistic locking
on concurrent write. Now, we have zipped these two interfaces into one interface that supports versioning/optimistic locking out of the box, for example:Domain layer components (Decider, View, Saga)
maptLeft***
functions are renamed tomapContra***
combine
method uses TypeScript intersections rather than Tuples to combine states asS1
&S2
. The previouscombine
method is renamed tocombineViaTuples
and is still available for usage.Tuples are more straightforward and may be more suitable for simple cases,
while intersections provide more flexibility and can handle more complex scenarios.
TypeScript adopts a structural type system that determines type compatibility and equivalence based on the type structure or definition rather than the declarative relationship between types and interfaces, which contrasts with the nominal type system.
We want to use this, not fight it! We want to provide a more robust tool to effectively model the domain!
Event Modeling
Event Modeling is:
Structuring the data
In TypeScript, we can use Algebraic Data Types (ADTs) to model our application's domain entities and relationships in a functional way, clearly defining the set of possible values and states.
TypeScript has two main types of ADTs: union types (
"|"
operator), intersection types ("&"
operator), tuples and recordsunion types
is used to define a type that can take on one of several possible variants - modeling asum/OR
type.intersection types
,tuples
andrecords
are used to combine several types into one - modeling aproduct/AND
type.ADTs will help with
In FModel, we extensively use ADTs to model the data.
C
/ Command / Intent to change the state of the systemE
/ Event / FactS
/ State / Current state of the system/aggregate/entityModeling the Behaviour
This leads to modularity in design and a clear separation of the entity’s structure and functions/behaviour of the entity.
Fmodel library offers generic and abstract components to specialize in for your specific case/expected behavior:
Decider - data type that represents the main decision-making algorithm.
The logic execution will be orchestrated by the outside components that use the domain components (decider, view) to do the computations. These components will be responsible for fetching and saving the data (repositories).
The arrows in the image (adapters->application->domain) show the direction of the dependency. Notice that all dependencies point inward and that Domain does not depend on anybody or anything.
Pushing these decisions from the core domain model is very valuable. Being able to postpone them is a sign of good architecture.
Event-sourcing aggregate
Beta Was this translation helpful? Give feedback.
All reactions