I'm currently splitting up a n-layered monolith into DDD.
I currently split up the following modules:
And moving to the OrderModule, which is the most complex one of course.
I am currently wondering about to split it up completely or keep all the Bounded Context the same.
This means, the order module will contain the following:
But i'm kinda wondering if i would split up the OrderModule into a OrderModule, ShippingModule and a PricingModule ( eg. for handling discounts)
Any advice? Or if more information is required. Please let me know what you expect.
I'm re-reading "Domain-Driven Design" right now. My gut says that splitting things up into modules makes a ton of sense. I'm not sure if I would carve out any bounded contexts, at this point. My take is that bounded contexts really excel when there would be naming clashes in the ubiquitous language. They are, probably, also useful if you have a large team and a team could own a bounded context, but I rarely work with teams of that size.
On a side note, there's nothing inherently wrong about a monolith. I'd wager that for the majority of applications, it's the correct architecture. You can have a DDD monolith without any problems. I see that several of the other comments echo this sentiment.
What?
DDD is just a way to understand and contextualize what you're building. It's not an application architecture.
You can use DDD to design monoliths or microservices or anything else.
I'd agree with the below comment that microservices are more of an organizational pattern than a technical one.
If it's just you, I'd suggest you stick with a monolith but use your DDD skills to define the modular boundaries in your code. Don't share code across those boundaries, just define interfaces for them to use to communicate, ideally in an async way (like messages). Modularize your data, too, and try not to cross those boundaries in queries.
I would initially keep the order module coarse-grained, it obviously depends on what knowledge you've already distilled but if you are incrementally partitioning that's what I'd do.
Also, a comment on one of your comments below, not necessarily a microservice entails a bounded context, e.g. you could easily have a microservice which implements a transaction script. If you give more info, I'll be happy to provide more feedback.
No, under no circumstances should you be going micro services, as it will do nothing but bring you pain. Micro services are a concept turned into fad by incompetent developers who want to make themselves sound cutting edge to land contracts, but aren't going to help your business any, because they don't actually know what they're doing.
The concept of micro services was designed for large organizations such as Netflix, and not for one-man shops such as yourself. The whole concept is to modularize a large code base to make manageability easier across TEAMS of developers. So unless you have a minimum of 20 developers working on this project, and a need to split them into teams so they can focus on their portion of the system, then micro services are of no use to you, and will only lead to complicate your life with unnecessary problems.
I can't give you a solid answer to your question, as you didn't provide a database schema at all. What you need is to either, learn better database design, or contract out to a qualified developer who knows how to write a clean and efficient database schema.
There's definitely a time and a place for microservices. I'd build on your comment by saying there are (at least) three places where microservices make sense:
Where team should or need to operate independently from one another.
Where portions (but not all) of the application has very different load parameters and load patterns.
Polymath applications, where multiple languages or platforms need to be used to accomplish the business objective.
I'm currently not going to ;)
First, I would say a monolith has to have customers, revenue, and be business critical. If you don't have customers or only have a few, how did you get to be a monolith? Second, I sort of feel, without having had to spit up a monolith, that keeping a monolith running is just throwing good money after bad and creating ever increasing technical debt that eventually you'll have to address.
I personally am a huge fan of microservices. The nice thing about them are that you can do a slow transition away from the monolith. You can replicate a small piece as a microservice, and slowly modify the monolith to point to the microservice. Once everything that uses that functionality is pointing to the microservice you can cut the old code out of the monolith (or leave it there if you're lazy). Then move into the next piece and so on. Eventually you have a distributed, microservice application without ever disrupting your users and without them seeing any changes.
The downside to that, slow, approach is that while you're replicating functionality and spitting things into microservices there is no features l development and very little bit fixes.
I don't think I'm really answering your question though. I think the bottom line is, is there any good reason to keep the monolith going? There's a reason monoliths are considered an anti-pattern these days and that's because they're a single point and hard to debug, support, scale, etc.
Hope that helps,
Microservices are just a way of changing programming complexity to devops complexity.
DDD is step one in splitting everything up, I have an API project on top of I want to integrate microservices. So that's not hard to do.
But I think it's very important that there are plenty examples of successfull and popular monoliths in the wild. Microservices mostly help with Conway's law ( lot of employees).
You, as you mentioned, haven't answered my question. But I'm not convinced that microservices are the holy Grail, since that is what your response led to.
Monoliths are easier to debug and faster to develop. If you apply clean code and a good structure ( which microservices enforce, as does DDD), the reasons to switch are few. Except for the hype of course ;) .
Ps. Any Junior developer can make even a microservice suck. Microservices just make it easier to replace it. Also microservices expect a bounded context, which mean they can get bigger than people expect.
Counter point: you say in your profile that you are "refactoring from monolith to DDD to microservices in that order", so it sounds to me that you agree that microservices is the way to go? I suggested a way to skip the DDD step and wasted effort that middle steps entail.
It sounds to me like we have very different opinions here since I would counter that any junior developer can make a monolith suck and that monoliths are often not easier to debug.
I'm currently in the process of splitting up to DDD and probably microservices.
I'm not saying that microservices are the way to go for a lot of use-cases. There is a lot of overhead involved.
It's also quite possible that I'm only going to refactor to DDD.
The biggest advantage is one that I mentioned before and that is enforcing bounded contexts.
I think most people want to pre-optimize before they have any customers. I have multiple monoliths with customers which I don't need to touch anymore and they are working fine.
I'm in the unique position now, that I have time to optimize for myselve and a customer who has a fairly nice budget to do so. I'm creating a shop platform and I'm one of the 2 customers which I have 6 shops to deploy for. One for myselve.
What I'm saying is that microservices shouldn't be a pre-optimization without customers. You don't need scale when you have no customers :). Distributed systems are a luxury problem that 90% of the web applications won't need.
The refactoring of microservices won't be a priority. I'm mostly intrigued by changing my dev patterns to an event based system, which DDD and microservices are a decent goal for. It's not a priority, my platform works and is highly performant ( <150 ms during load tests, including js. My basket even loads in 20 ms(*)).
Also, I'm not going to implement micro-frontends very soon. Which kinda defeat the purpose of microservices ;)
We partially say the same yes, but your make it seem like a requirement. I'm saying that it's not important, but useful for learning porpose.
(*) An API gateway ( BFF) would give an additional lag of 40-50 ms, which would greatly reduce my performance metrics score ;)
Ps. Debugging in microservices is a matter of having all the requirements checked ( correlationId, ... ). Without them, good luck to follow a path.
There are also a lot more health-checks to do + patterns to implement ( eg. Outbox)
Things also become harder ( eg. Saga orchestration for a simple state machine)