-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feedbacks #1
Comments
I think the main problem of implementing DDD in Go is the lack of data mapper ORM which provides entity change tracking. If you manage to provide guidance on how to implement repository save method and how to update aggregate child entities this could become big. |
@jzvelc Thank you for your comment! I'll try it! |
Before looking into ORM's, please read this blog by "Uncle Bob"; https://blog.cleancoder.com/uncle-bob/2013/10/01/Dance-You-Imps.html |
@ferdypruis Thank you! I'll read it first. |
OK, I read it. I perfectly agree with:
This is also the same as the Domain-Driven Design way, so I'm completely convinced. And then, I'm thinking about the solution of
|
@jzvelc I investigated GORM doc, and found this: Could you solve the problem with this? |
Ah, You mean I should include this gorm function sample into goilerplate?? |
Provide an aggregate which holds a collection of children entities and show how to update child entity. There are two types of repositories. Collection based and persistance based. With data mapper orm where you have auto change tracking you normally use collection based repository. Any changes made to child entity are automatically peristed when unit of work is comitted and no persistance logic leaks in application/domain layer. With active record persistance based repository is more suitable. However I didn't find any examples how to properly work with child entities. You only have a repository per aggregate and changes to child entities are made through the aggregate root. One possible solution I thought about would be to raise domain event for every state change and repository could react on that. |
The way to have a repository per aggregate where changes to child entities are made through the aggregate root is the Domain-Driven Design one. So, I'll implement it via this way. Thank you for your detailed explanation. |
Hello. Did you consider using any Dependency Injection (DI) tool instead of doing manual DI ? |
@akoufa Thank you for your comment. |
@resotto For this sample project yes but if the project grows bigger the cost of introducing it is constant and the manual DI cost will grow and supersede the initial cost of Wire |
@akoufa I think it is trading off in the end. When injecting dependency manually,
When injecting dependency with tool,
However, it depends on which one you find easier. |
Now, I'm working on implementing get/save of a little bit complicated entity's repository. |
@jzvelc I implemented child entity update: I think we can know in advance which properties of child entity will change, so we don't have to do everything in one save/update method. |
@akoufa I considered Wire but I felt its cost is not low. Moreover, Goilerplate might depend on it since DI tool such as Wire is some kinds of Application Framework, I think. So I tried to reduce the cons side of Manual DI and this is the result of it: https://github.com/resotto/goilerplate#dependency-injection |
@resotto I think I have an improvement suggestion regarding the manual DI example of yours. For example instead of creating the dependency graph every time a new request is being handled you could extract the DI code to the startup of the Service. You could find a good example of how this is done https://github.com/eldimious/golang-api-showcase/blob/master/server.go . Here the Dependency Graph is build up in the server.go file which acts as an entry file which coordinates the setup of the service. Maybe something similar would work for Goilerplate ? |
@akoufa Thank you! I'll check it! |
Aha, in manual DI, the number of implementation initialization will be expensive. So, I'll try to reduce it by using global variable. @akoufa This codes you gave me was helpful. Thank you. |
Now, we might fail pulling I'm investigating. WorkaroundLet's build docker image from Dockerfile and run it. docker build -t goilerplate-pg:latest .
docker run -d -it --name pg -p 5432:5432 -e POSTGRES_PASSWORD=postgres goilerplate-pg:latest |
please go to discussion |
Feel free to write your thoughts.
The text was updated successfully, but these errors were encountered: