Git Product home page Git Product logo

go-ddd's People

Contributors

dependabot[bot] avatar sklinkert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

go-ddd's Issues

Question: abstract vs concrete entities

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:

type Seller struct {
Id uuid.UUID
CreatedAt time.Time
UpdatedAt time.Time
Name string
}

This concrete Seller struct is then used in the SellerRepository interface:

type SellerRepository interface {

And subsequently in the PostgreSQL implementation:

func (repo *GormSellerRepository) Create(seller *entities.ValidatedSeller) (*entities.Seller, error) {

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:

  1. What are the advantages of using a concrete Seller struct in this context?
  2. How does this approach align with DDD principles?
  3. Is it accurate to say that your abstract interfaces, when used, return the concrete Seller entity?

I appreciate any insights you can provide to help clarify these concepts.

Thank you for your time!

Please tell me how to add these services based on the current code structure?

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.😀😀

[Question] About pointers

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.