In my company we have two "applications" - one is essentially a big CMS for product department to manage products, promos, customers etc. The second one is more or less e-commerce solution which is a direct consumer of CMS bounded context. The thing is, we share infrastructure - mainly databases. This is the origin of Product in e-commerce BC - it's loaded from table maintained by CMS. In Implementing DDD by Vernon author mentions several ways to integrate such remote BCs (REST/RPC/Messaging) but I haven't encountered that scenario anywhere. From performance perspective it's probably (and correct me if I'm wrong) best to use those CMS tables in e-commerce BC.
Now:
Should I create a Inventory context in e-commerce that would serve as a integration bridge between CMS and e-commerce BCs?
Should I move persistence models from CMS to some kind of shared kernel and use it on both BCs?
What are my options here?
Database integration is an option also, although it is not desired by DDD.
You may use rpc query from the CMS hidden behind a domain service or ProductRepository in e-commerce bounded context if you want to avoid direct database manipulation. I believe this is the minimal cost approach.
On the other hand, e-commerce bounded context may have its own database, the product data needed could be replicated by messages published by CMS bounded context. But I think it is a big overhaul on both bounded contexts.
Related
I'm starting on DDD and I have a doubt on application of DDD on a Web Project.
If I have multiple Bounded Contexts for every section of a web project. For example, "Catalog" and "Shopping Cart" on a E-Commerce project. ¿Where should be the code that implements the frontend for all the Web and presents concepts from many Bounded Contexts?
I have thought about creating the "Web" Bounded Context, but this Bounded Context won`t represent a specific Ubiquitous Language because this BC will use concepts of many Bounded Contexts and Subdomains.
What you do think about this?
Thanks.
Where this code goes depend on the structure of your application.
DDD is a set of patterns and rules that helps you model your business. This model should be ubiquitous, meaning different applications should share the same business logic. The main rule of DDD is what describes the business goes in the domain, everything else does not. DDD does not state anything about how to you should structure your application, it can be applied to any architecture.
What you describe is called presentation logic and does not describe your business logic. It describes how your system interacts with clients, which are external actors and is specific to your application: if you make a web or a mobile version of your app, chances are that you will have the same domain implementation but your presentation logic will slightly differ. So, there is no DDD answer to where the presentation logic goes, besides not in the domain.
If you make a traditional 3-layered application, this logic goes in the presentation layer.
I am new in microservices. I am coming from monolithic background in current environment i have different kinds services for different purposes like search, file, email, notification. I have taken so many courses but in that the instructor separate each entity and make it's own database also create API for that(like separate shopping cart entity, product entity) it makes no sense, I am not getting what is real world use of microservices or how to make separate component to build it's own microservice.
Can anyone give Real Project example?
Thanks in advance
Read this and this. Also look here and here. I don't think that anyone will give a link to the real working project, so you can try this.
I am not getting what is real world use of microservices
mostly as you heard in all of those tutorials the microservices architecture leverage advantages of:
the smaller services are easy to maintain and develop
easily can scale specific services rather than the whole project(monolith). for example you scale service-1 to 4 instances that request traffic split into these 4 instance and service-2 to 2 instances and go on (load balance). and these services may distributed in to different servers and locations.
if one service failed to work it does not terminate the whole system since they are independent.
services can be reusable for other scenarios or features.
small team can works for each services and its easy to manage both project and development flow.
and also it suffer from disadvantages of
services are simple and small but all as a whole system is complex so designing part are very critical.
poor performance and it requires do some extras to improve the performance (different types of caching on different levels).
transactions are complex and its developments are time costly. imagine simple update should be projected to other services if its required and you have to consider failure and rollback strategy ( SAGA ).
how to make separate component to build it's own microservice
this is the most challenging part of microservices. you need deep study on Domain driven design DDD.
Decompose by subdomain
Decompose by Business Capabilities
Can anyone give Real Project example?
there are many projects the develop microservices with different patterns. I think you have to start your own and make your hands dirty.
I am quite new to DDD and have come across a scenario that i'm not to sure how to handle.
I have an application that is used to track vehicles. This application is what will be implementing the "core" of the domain for the business i am working for. Not only is this application going to be used, there will be other utility programs that must be created and used in order to help this "core/main" application function.
for example:
there is an windows service needed that will perform configured queries on a database and return results to an external database that my routing application will use. This windows service has the concept of a QuerySettings class that can be created and is then executed by this application.
Question1:
What do you call utility applications like the above described in DDD? ( it definitely isn't the main core of the domain but it's needed in order for the core application to work )
QUestion2:
Is QuerySettings a domain model? if not what is it and where should it be placed within following the onion architecture?
For question1: You may have a look at Bounded context, I think Bounded context contains a group of Domain models that represent concepts in a subdomain(or a core domain). You may need to map or share domain models in different bounded contexts to handle your business, this depends on your bounded context strategy, share-kernal, anti-corruption-layer(to name a few).
For question2: I have little information of how QuerySettings works but in general it is a domain model but in a generic subdomain, not in your vehicle tracking core domain. In core domain's view, it maybe an infrastructure concept.
Here is my scenario,
We are developing an ordering application for which the propducts should come from another system which has the product catalogue and rules for product offerability. We communicate with them through webservice.
Forming the service request to get the products involve more business logic for which i have to refer other entities like Address, customer profile , Marketing Strategy Rules , etc.
If i think of making the call inside product repository to populate the product entities , is it appropriate to refer the other entities and have such complex logic inside product repository ?
Some of them suggest to use Application Service , but i am not clear as from my understanding application service talks with domain and infrastructure to complete a specific task. And it will not hold any business logic.
What is the appropriate place and best way to do this ?
I recommend using a domain service and implement it with adapter calling webservice.
Repository strategy means you need to have product as an aggregate in your ordering bounded context. But product category and pricing is not the core domain in ordering bounded context. therefore you may not need product as an aggregate. I think you just need some simple value object in order aggregate to record what product is booked. hide other product' stuff behind a domain service.
An good example is cargo RoutingService mentioned in eric evans' DDD book.
According to DDD repositories should not contain any business logic. They should be simple tools for your domain layer to access and manipulate persisted data. All business logic should be held by domain services, aggregates, entities or value objects.
With all due respect, since this is very clearly written in all DDD manuals I suggest you (re)read them.
Good luck!
A good discussion on architecture:
Domain driven design repository implementation in infrastructure layer
Application layer is good, but their interface must be in the core project
I would like to use DDD\CQRS\ES in my project. I just started using it so I don’t have a lot of experience. I am aware of existing core domain, supporting domain and CRUD domain. My core domain have references to CRUD data. For example There are a lot of business rules in Order, but it contain basic information about Delivering Company, receiving point etc.
These informations are managed by admin. In my opinion I should use crud approach but what happen when I need to rollback events?
System is going to store mix of data – restored from event source and actual from crud part of app. I will end up with inconsistent data. For example, The order may be maintained by not existing company ( That company was deleted by admin when their have delivered package, but after rollback order is still active)
In every project is part of CRUD data so how do you deal with this problem?
Should I store company events?
Additionally, When I’m adding new order I should send company name and id via event because when Im rebuilding my ReadStore , there may not be company in database so I can’t get companyName from repository
PS. Do you know any CRUD framework to handle with simples CRUD operations?
PS.2 Do you know any example opensource project which containt CRUD part of app in ES\CQRS approach?
Ok. Maybe I described it too complicated. I just want to know:
how to implement the simplest part of application ( poor business
logic - mainly CRUD operations) when I store my core domain in
event store and I would like to be able to revert previous state of
my core domain
Should I store crud operation in event store too or not?
How provide data consistent after rollback event store?
Which CRUD framework do you recommend for Java applications?
I think this is a common problem when dealing with DDD and especially when dealing with ES. This might sound simple but what you need to look for are the bounded contexts in your domain. Turns out that this bounded contexts map very well onto the services from SOA. Now when you get to SOA you realise that not all the services ( service as the S in SOA not as in web/windows service ) need to be implemented the same.
In my experience you are always going to have some services dealing mostly with CRUD operations and very little business logic, usually consumed by apps that are used by admins/special users. This services can and should be implemented with the least effort possible, without CQRS and ES and without over complicating them. Just make sure they publish relevant messages when something happens.
I strongly recommend Eric Evans - what i've learned about DDD since the book video.
Also Udi Dahan has some very very good videos about SOA and what SOA means: Avoid a failed SOA and Udi on SOA
I realise this is not actually answering all the details of your question, but i hope it will point you in the right direction.
Why not simply treat the CRUD part as append only (maybe allow update if you must) or copy enough data into the event such that important data isn't lost?
I don't what exactly your trying to ask, but if it concerns DDD and CRUD operations, the Cocktail framework might help you although i haven't tried it my self.