Похожие чаты

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 ответов

13 просмотров

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

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

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

как правильно удалить сддм? прописал в etc/portage.use/plasma-meta -sddm , но при обновлении юзов мне предлагает поставить lightdm (ещё лучше 😡), добавил туда - display-manage...
REDis
25
Except the wealthiest, people that buy crypto want to "cash out" at the end of the day, one way or another. Converting to fiat is craziness, converting to BTC is unwise. Hold ...
Erdelanax
2
#include <stdio.h> #include <stdlib.h> #include <time.h> void mass_first_generate(int mass[5][7]) {     for (int N = 0; N < 5; N++) {         for (int A = 0; A < 7; A++) {   ...
Чувак
6
Всем привет! Решаю 99 OCaml Problems и столкнулся со следующей проблемой (прошу палками не забивать, я OCaml практически не трогал до этого момента): open OUnit2 let create_...
К|/|pи/\/\ 6е3yглbIи
2
Всем привет! Имеется функция: function IsValidChar(ch: UTF8Char): Boolean; var i: Integer; ValidChars: AnsiString; begin ValidChars := 'abcdefghijklmnopqrstuvwxyzABCDE...
Евгений
44
возможно ли как-то передать в электрон или таури медиа поток с рендера 2д движка? двиг запускается как dll, а дальше надо как-то отправлять рендер кодировать не подходит, зр...
Kyle Nekto
7
https://www.linkedin.com/posts/ugama-benedicta-kelechi-codergirl-103041300_mobiledevelopment-fluttertraining-handsonlearning-activity-7263445699227254784-IdHB?utm_source=share...
CoderGirl
16
like, question: int b = 99999; is this valid and predictable C?
Ludovic 'Archivist' Lagouardette
15
Помогите пожалуйста. Делаю систему плагинов. Проблема сейчас в такая: плагины загружаются в основном потоке. FLibHandle := SafeLoadLibrary(FFileName) Но нужно еще выполнить фу...
Илья 🤣
10
VIP-397 BNBx Oracle implementation upgrade Summary This proposal, if approved, will upgrade the implementation of the BNBx Oracle contract on Venus from version 1 (V1) to v...
Venus Announcements
2
Карта сайта