Похожие чаты

Hi Everybody, I have a question about Clean Architecture and

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?

24 ответов

30 просмотров

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.

Насер-Мирзаи Автор вопроса
jeffotoni
so, if you are using DDD as mentioned, I believe y...

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) }

Насер Мирзаи
a friend suggested to use post service in comment ...

it's a way, so you can implement the interface in your other comments service

Насер-Мирзаи Автор вопроса
jeffotoni
it's a way, so you can implement the interface in ...

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.

Насер-Мирзаи Автор вопроса
jeffotoni
it's a way

any other suggestions you have?

Насер Мирзаи
any other suggestions you have?

so, another way would be to make the pkgs of your services when they are public/global

Насер-Мирзаи Автор вопроса
jeffotoni
so, another way would be to make the pkgs of your ...

you mean using both services in an endpoint or transport layer (names are from gokit.io)?

Насер Мирзаи
you mean using both services in an endpoint or tra...

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

Насер Мирзаи
Thanks a lot!

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.

Насер Мирзаи
Thanks a lot!

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.

Насер-Мирзаи Автор вопроса
jeffotoni
I don't have all the examples here, but if I had I...

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)

Насер Мирзаи
I read some implementations of DDD+Clean Arch befo...

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.

Насер-Мирзаи Автор вопроса
jeffotoni
it is very swollen, dense and clean, it has nothin...

I use an instruction near to it. for example I don't use endpoints and I think we can skip it ;)

Насер Мирзаи
I use an instruction near to it. for example I don...

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

Насер-Мирзаи Автор вопроса
jeffotoni
🥳🥳🥳😊

Wow, look at the sensei here hehehe

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта