Domain Driven Design:
Imagine you have a Blog API with 2 services: Post & Comment
When you want to add a comment to a post, where should you check the post exists or not? in comment service (by calling the post service method)? in the earlier layer who calls create comment method? or else where?
so, if you are using DDD as mentioned, I believe you will implement, Get, Post, Update everything in your POST service. And when iimplementar Comment will reuse it. But I am weak in this model, I don't use much DDD around here, most services are defragmented and this GET would be a repo being reused by any module that wants to use it.
a friend suggested to use post service in comment service to check post exists or not. but with an interface: type PostIDVerifier interface { PostExists(ctx, id) (bool, error) }
it's a way, so you can implement the interface in your other comments service
yep, and post service doesn't depend on comment service. also comment service just need an implementation of the inteface it needs, not the whole post service.
any other suggestions you have?
so, another way would be to make the pkgs of your services when they are public/global
you mean using both services in an endpoint or transport layer (names are from gokit.io)?
so, as I said, it has several paths. if you choose to use the DDD you can follow the path above. If you are going to do a defragmentation of the service for example you can create a pkgs and reuse it whenever you want using or not using the interface in the way you find most flexible and easy. And you can also implement something like a go kit - like microservices if you want. If you are going to do something monolith it makes sense your DDD way
to make it clearer, and maybe it will clear up your doubts much better than just talking around here. it implements something simple using interfaces and DDD, it implements a decoupled pkg or repo and it implements a global pkg or repo to reuse and with this you will understand in practice when using each of them models and architectures.
I don't have all the examples here, but if I had I would send it to you, what I have here are private But I'll see if I can later make some models available for you to have an idea. Another detail, you don't need to be stuck with any of this, and you can use it in the way that is best for you.
I read some implementations of DDD+Clean Arch before, but to be honest I didn't like their ways. the most adorable way is gokit IMO (if you name that DDD+Clean)
it is very swollen, dense and clean, it has nothing, in my view it becomes even more boring to keep it growing as things get more complicated.
I use an instruction near to it. for example I don't use endpoints and I think we can skip it ;)
This is very good in Go, the flexibility and freedom that we all have in implementing models according to our needs
I ended up reading an excerpt from the book Go, and he tries to present DDD using Go, and he calls DDD Lite. Maybe it will help you to clarify even more about it when using Go https://github.com/ThreeDotsLabs/wild-workouts-go-ddd-example
❤️ I'll read that soon
Wow, look at the sensei here hehehe
the group here is also very good
Wonder, the more the better.
Обсуждают сегодня