Giter Club home page Giter Club logo

Comments (3)

draphyz avatar draphyz commented on May 28, 2024

Hi,
Your question is difficult because it depends on your software architecture. But I advice you to centralize and test the code of your application layer in libraries as in my example and to use a dependency injection library in your application to configure your command and query handlers. Then you can use and create commands and queries in your controller or presenter and process these commands and queries with a query or command processor based on dependency injection (you can find here an implementation of a command processor based on dependency injection). In a microservices architecture, commands, queries and results of queries are just DTOs used in the API of a microservice. This API is fine-grained and is often not exposed to your client but used by an API gateway that defines a coarse-grained API adapted to your client's needs.

from ddd.

h-fathi avatar h-fathi commented on May 28, 2024

Thank you for answer,
I working on your sample project "HealthcareDelivery" and I've trouble injecting dependency into the API layer. Would you please make API layer for "HealthcareDelivery" project and inject dependency or help me make it.

Thanks in advance

from ddd.

draphyz avatar draphyz commented on May 28, 2024

Hi,

It's a good idea. I've already thought about it but I don't have time at the moment to implement it. I will do it soon. You can get inspired by this chunk of code using SimpleInjector :

var assemblies = GetAssembliesToScan();
container.Register(typeof(IMappingProcessor), () => new MappingProcessor(container));
container.Register(typeof(ICommandProcessor), () => new CommandProcessor(container));
container.Register(typeof(IQueryProcessor), () => new QueryProcessor(container));
container.Register(typeof(IEventPublisher), () => new EventPublisher());
container.Register(typeof(ICommandHandler<>), assemblies);
container.Register(typeof(IQueryHandler<,>), assemblies);
container.Register(typeof(ICommandValidator<>), typeof(FluentCommandValidatorAdapter<>));
container.Register(typeof(IQueryValidator<>), typeof(FluentQueryValidatorAdapter<>));
container.Register(typeof(IValidator<>), assemblies);
container.Register(typeof(IRepository<>), assemblies);
container.Register(typeof(IObjectTranslator<,>), assemblies);
container.Register(typeof(IObjectMapper<,>), assemblies);

from ddd.

Related Issues (1)

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.