Design Patterns

     

design patterns




what is DDD (Domain Driven design)

saga design pattern

API gateway design pattern

adapter design pattern

event sourcing 

CQRS



what is event sourcing 


it is adding an event at every stage crossed by an entity. This acts nicely for auditing and so much more than that.

For any entity the current state can be reached at by replaying the events it has gone through.

Event tracing gives a trail of chronology of stages through which the entity has eveolved.



the event sourcing addresses a challenge of implementing an event-driven architecture.

Event sourcing pattern has an event store which acts both as a DB and a message broker.


An entity keeps persisting its states in the store during its lifecycle. And the subscribing parties can fetch reqd info from the 

event store about particular entity.


event sourcing helps enable event-driven arch.


Read more: https://javarevisited.blogspot.com/2021/09/microservices-design-patterns-principles.html#ixzz7ra2LuRjk





What is CQRS:

- command and query responsibility segregation


- The command & query responsibilty is segregated here.


- what it means is,


Basically what cqrs enables us is, there should be separation of concern 

(1. concern while writing/posting  data 

2.  concern while reading/getting  data )


Hence CQRS suggests below models:-

command model is used to write data to DB

and query model is used to read data from DB.


This in turn increases control over application entity.

and the data contention (dirty/ inconsistent data) is reduced.


CQRS lets us create a more sophisticated 'view' of Data to be read. And hence increases security.

E.g. we use DTO objects to send data back (for read) and prevent our entity model from being exposed to outside world. (e.g. from logs, etc.) 


Comments

Popular posts from this blog

What is microservice ?