Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements/reconsidering the Adapter set-up and Modules mechanisms #356

Open
alelom opened this issue Mar 8, 2023 · 0 comments
Open
Labels
type:feature New capability or enhancement

Comments

@alelom
Copy link
Member

alelom commented Mar 8, 2023

Description:

As seen here: BHoM/ETABS_Toolkit#422 (review)

We had an unpredicted failure because of the following:

  • we are constructing the functionality at runtime of a class (ETABS_Adapter) from within the class' constructor;
  • this functionality depends on another service (modules) which itself depends on the correct configuration of the class (ETABS_Adapter's Id).
  • The service module is not injectable via the ctor but is required to exist independently.

Because we had the incorrect ordering of instructions in the ctor (we declared the modules before the setting of the AdapterId), this raised a failure in the module loader, which required the AdapterId to be set.

Ideas

Possible solutions commonly adopted that require reworking the current architecture are:

  • Dependency Injection: e.g. ctor injection via an IoC container
  • Inheriting a base abstract adapter that exposes the functionality

Other solutions keeping current architecture are:

  • adding the dependency on AdapterId on the modules
  • making sure AdapterId is set before entering the ctor:
    • adding a static ctor
    • setting it as default value, never inside the non-static ctor
@alelom alelom added the type:feature New capability or enhancement label Mar 8, 2023
@alelom alelom changed the title Reconsider the Adapter Modules mechanism Improvements/reconsidering the Adapter Modules mechanism Mar 8, 2023
@alelom alelom changed the title Improvements/reconsidering the Adapter Modules mechanism Improvements/reconsidering the Adapter set-up and Modules mechanisms Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New capability or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant