Skip to main content
added 188 characters in body
Source Link
k3b
  • 7.6k
  • 1
  • 21
  • 31

how can my other layers use this implementation

At compile time all other layers can "use" (= "depend on" = "know the definition of") the interfaces that are defined in the the core (i.e. IExternalDep or ICustomerRepository).

What is the way to provide the implementation at runtime without directly depending upon the Infrastructurewithout directly depending upon the Infrastructure

The answer is Dependency injection.

Your busineslogic and uscases only depend on the interfaces in the core.

There is an initialisation module that knows all classes and interfaces that wires up your applicationyapplication. This initialisation module also knows (depend on) the classes of the infrastructure layer. The wireup tells your usecase which implementations to use:

public void wireupMyApp() {
 ICustomerRepository customerRepositytory = new MyDatabaseCustomerRepository(....);
 MyCustomerUseCase customerUsecase = new MyCustomerUseCase(customerRepositytory, ....);

}

how can my other layers use this implementation

At compile time all other layers can "use" (= "depend on" = "know the definition of") the interfaces that are defined in the the core (i.e. IExternalDep or ICustomerRepository).

What is the way to provide the implementation at runtime without directly depending upon the Infrastructure

The answer is Dependency injection.

There is an initialisation module that knows all classes and interfaces that wires up your applicationy.

public void wireupMyApp() {
 ICustomerRepository customerRepositytory = new MyDatabaseCustomerRepository(....);
 MyCustomerUseCase customerUsecase = new MyCustomerUseCase(customerRepositytory, ....);

}

how can my other layers use this implementation

At compile time all other layers can "use" (= "depend on" = "know the definition of") the interfaces that are defined in the the core (i.e. IExternalDep or ICustomerRepository).

What is the way to provide the implementation at runtime without directly depending upon the Infrastructure

The answer is Dependency injection.

Your busineslogic and uscases only depend on the interfaces in the core.

There is an initialisation module that wires up your application. This initialisation module also knows (depend on) the classes of the infrastructure layer. The wireup tells your usecase which implementations to use:

public void wireupMyApp() {
 ICustomerRepository customerRepositytory = new MyDatabaseCustomerRepository(....);
 MyCustomerUseCase customerUsecase = new MyCustomerUseCase(customerRepositytory, ....);

}
Source Link
k3b
  • 7.6k
  • 1
  • 21
  • 31

how can my other layers use this implementation

At compile time all other layers can "use" (= "depend on" = "know the definition of") the interfaces that are defined in the the core (i.e. IExternalDep or ICustomerRepository).

What is the way to provide the implementation at runtime without directly depending upon the Infrastructure

The answer is Dependency injection.

There is an initialisation module that knows all classes and interfaces that wires up your applicationy.

public void wireupMyApp() {
 ICustomerRepository customerRepositytory = new MyDatabaseCustomerRepository(....);
 MyCustomerUseCase customerUsecase = new MyCustomerUseCase(customerRepositytory, ....);

}