Which design pattern Abp Framework (abp.io) are developers using?
Asked Answered
P

1

6

At my company we are using the brand new Abp framework (abp.io). As it's a new framework, lots of documents are missing so we have to search at source code. Looking so much at the code I realized that's a pattern they're using that always appears Providers, ProvidersManagement, DefinitionProvider and so on. I would like to know if this pattern has a name or it's something just used there. I don't believe it's second option but I don't know.

Feature Module, Settings Module, Permission Modules are all module that are implemented using such design pattern.

Thank you guys!

Prisage answered 15/7, 2020 at 22:29 Comment(2)
Actually, lots of documents are not missing. :) docs.abp.ioStylo
yea, we're working on this framework all day long for some weeks and I'm pretty sure it's missing. but don't you know the name of this pattern design? it'll help a lot understanding betterPrisage
L
11

I wanted to answer the question as the programmer behind these patterns in the ABP framework;

First of all, I want to explain why we are introducing these "provider" style pattern. The main reason is extensibility: A developer can extend the system by just implementing a provider interface and registering it to the framework. In this way, you don't need to replace or override a complete service to add a new behaviour.

For example, PermissionChecker service loops through the providers (those implement the IPermissionValueProvider interface) to allow you to decide if the current user has the requested permission. There are some pre-defined permission providers: user provider, role provider... etc. User provider checks if the current user has directly authorized for the permission while role provider checks if any role of the current user has the required permission. You can simply create a new provider implementation that checks the permission in a different way and allows the users to perform the related operation.

There are similar patterns used in the ASP.NET Core too.

For example, ASP.NET Core request localization middleware uses a similar pattern to determine the current culture for a web request. There are QueryStringRequestCultureProvider, CookieRequestCultureProvider... classes tries to determine the culture from different sources. It is also extensible, you can register new providers or re-order current providers.

We generally name such classes as "provider" or "contributor" in the framework.

Contributors are different classes those are participants of an operation. For example, for the menu system, there is a IMenuContributor interface that you can implement and take part while building the main menu in the application (add/remove/replace menu items).

The pattern is also similar to "Chain of Responsibility" pattern. For example, IPermissionValueProvider is similar to CoR pattern since each provider tries to check if the current user has permission for an operation. If the provider doesn't know that, the next provider is executed.

So, I don't know the exact name and I didn't 100% copied a pattern while implementing these. If this is a new pattern (I don't think so, but) I am not good at naming pattern, let's ask to Martin Fowler :)

BTW, we are constantly improving the documentation of the ABP Framework. In the previous milestone, we've completed most of the fundamental documents (like UOW, distributed event bus... etc). Recently, completely revised and extended the startup tutorial. Documentation will be a high priority in the next milestones too.

Thank you for using the ABP Framework :)

Leeannaleeanne answered 16/7, 2020 at 19:44 Comment(4)
thank you! it's very good to hear from you. so if I understand correctly, if I write a provider, for example the setting, will I have to build the store? We're having this problem right now. We are defining settings, permissions, features and we don't know how it will be saved, etc.. we're looking for the examples but until now, we discovered nothing. and by the way it's a great framework. we were using the old Aspnet Boilerplate but now we're migrating to Abp (in the last 3 weeks), that's why we have so much doubts about this system yet. thank you again!Prisage
you can save settings in appsettings.json or in the database (AbpSettings table) or in the environment variables. docs.abp.io/en/abp/latest/Settings ABP extends ASP.NET Core Configuration system. learn.microsoft.com/en-us/aspnet/core/fundamentals/…Moonshot
feel free to ask your questions and issues to GitHub Issues (github.com/abpframework/abp/issues) also you can check out official twitter account and SoF community.Orissa
Just to add my subjective 5 cents to the discussion, I don't think naming makes things extendable, design does. Simple concrete names makes it easier to reason about code. Names like Providers, Managers, etc. are vague and make you more disoriented, I would rather avoid them as much as possible.Dumanian

© 2022 - 2024 — McMap. All rights reserved.