sklinkert / go-ddd Goto Github PK
View Code? Open in Web Editor NEWGo Domain Driven Design Template / Reference
License: MIT License
Go Domain Driven Design Template / Reference
License: MIT License
Hello,
Thank you for creating this repository. I'm new to both DDD and Go, and I have a question about your implementation of entities and repositories.
I noticed that the Seller
entity is implemented as a concrete struct:
go-ddd/internal/domain/entities/seller.go
Lines 9 to 14 in 47abbf6
This concrete Seller
struct is then used in the SellerRepository
interface:
And subsequently in the PostgreSQL implementation:
My understanding of DDD suggests that entities should be abstract. While your Seller
entity is concrete, it's primarily used through abstract interfaces. Could you explain the reasoning behind this design choice?
Specifically:
Seller
struct in this context?Seller
entity?I appreciate any insights you can provide to help clarify these concepts.
Thank you for your time!
Thank you very much for sharing about DDD.
In actual projects, it is often necessary to start one or more background services to synchronize the database cache and check the status to ensure that the service is available.
Please tell me how to add these services based on the current code structure.
Best wishes.😀😀
Hi guys, I was checking the code and a question came up:
in product_service.go this function returns a pointer to the ProductService struct
func NewProductService(
productRepository repositories.ProductRepository,
sellerRepository repositories.SellerRepository,
) *ProductService {
return &ProductService{productRepository: productRepository, sellerRepository: sellerRepository}
}
but in infrastructure layer product_repository.go this function returns a ProductRepository
interface and the method returns a pointer to the concret implementation: GormProductRepository
.
func NewGormProductRepository(db *gorm.DB) repositories.ProductRepository {
return &GormProductRepository{db: db}
}
From my point of view the NewProductService function should return the interface type to ensure that the consumer has access only to the public methods defined by the interface.
I would like to know the difference between these cases, thank you very much.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.