Search code examples
dependency-injectiondomain-driven-designaspnetboilerplate

What are Modules in aspnetBoilerplate?


aspnetBoilerplate is based on Domain Driven Design design pattern.

I see that aspnetBoilerplate compose an application using modules.

I didn't understand what a module is , i searched it's definition in the context of domain driven design and i found that it serves as a container for a specific set of classes of an application.

So does that means ,For example , in c# namespace is a module because it can contains many classes ?

But even with this definition , it's not clear in the context of aspnetBoilerplate, a module defintion in aspnetBoilerplate have this structure :

  public class MyBlogApplicationModule : AbpModule
 {
     public override void Initialize()
     {
        IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
     }
  }

so it's just one class,that have one method !

Also what is the relationship between model and dependency injection ?

Why there is a registration of the model as a service in an IocContainer?


Solution

  • Abp module is just a way for you to organize your code under the same domain/layer and at the same time still being able to configure/interact with other modules

    E.g. your module is a separate library project that contains certain domain logic, to initialize your module correctly, you can place the initialization code in module life cycle hooks

    Note: register DI in the life cycle hooks is an example of interacting with the DI service (that might be configured outside of your project)

    See https://aspnetboilerplate.com/Pages/Documents/Module-System#lifecycle-methods

    Abp provides convenient way to register classes that follows the convention

    IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());

    Note: the recommended way is to only have a abp module per assembly

    See https://aspnetboilerplate.com/Pages/Documents/Dependency-Injection#registering-dependencies