-
Notifications
You must be signed in to change notification settings - Fork 553
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
[ENH] ContainerBase Should Not Inherit From ThemeBase #4886
Comments
Oqtane already utilizes interfaces. For example, the IModuleControl interface defines the core properties which a module component can implement. However due to the fact that interfaces are immutable it is essential to create an abstraction so that third party developers do not take a direct dependency on an interface (as otherwise, anytime the interface changed it would result in a breaking change). The way this is accomplished is by including a base class (ie. ModuleBase) which implements the interface and acts as an abstraction layer. This way a module developer can take a dependency on ModuleBase and not need to worry if the interface changes. This is a well accepted architectural approach when creating a framework/platform (which is not common when building applications as you do not need to worry about compatibility). The base class also provides some common utility methods and events to provide standard, simplified methods for interacting with the framework. |
I think what you are actually trying to report in this issue is that ContainerBase has some inconsistencies. It implements IContainerControl (which is the standard pattern I described above for ensuring backward compatibility) however IContainerControl does not have any properties defined. And ContainerBase inherits from ThemeBase - which means it inherits a bunch of functionality related to themes which is not 100% applicable to containers. This was implemented 4+ years ago and I believe the rationale at the time was that there was enough overlap in theme and container functionality that it did not make sense for containers to have their own distinct implementation (which would essentially duplicate the majority of functionality in ThemeBase). However, as the framework evolved there has been more divergence between theme components and container components, so this rationale may no longer be accurate. So from a purist perspective it might make sense to consider a change... but from a practical perspective it depends on how disruptive it will be for existing themes (ie. from a compatibility perspective). This will require some investigation. |
I understand that and there is quite a lot going for this. What I don't like is three things:
What I think would be more elegant is a "pure" base class which only does the necessary minimum and no overhead or additional APIs. Since you have the (absolutely justified) concern for the base class which may need to be enhanced by the platform itself, and the current
Something like this - and equivalent raw/bare-metal components. |
I am not in favor of changing the architecture for the sake of "purity". The Oqtane Philosophy (https://www.oqtane.org/blog/!/20/oqtane-philosophy) outlines that we are trying to use "Practical Engineering" and "Consistency" so that we can avoid these types of subjective topics. However, it should be noted that you should be able to create your own custom base classes, as long as you implement the required interfaces. |
@sbwalker Creating a lightweight I can implement the oqtane.framework/Oqtane.Server/Repository/ThemeRepository.cs Lines 304 to 313 in c819058
There it will ask for the I hesitate to implement I would suggest
Side Note: When I'm reviewing the code my impression is that Container |
I was reviewing this yesterday. The only IThemeControl interface property which is not applicable to container components is Panes... all of the other properties are applicable: Name - provides "friendly" name for a container component If ContainerBase did not inherit from ThemeBase it would need to support all of the same default services, state objects, and helper methods which exist in ThemeBase - so basically the only difference is that it would not include |
I guess this makes sense. From my point of view I would prefer if ATM the interface is there, but it doesn't serve a purpose, since implementing it won't actually result in the container being loaded. |
Oqtane Info
Version - 6.0
Describe the enhancement
At the moment many Oqtane controls - including containers and themes - MUST inherit from an Oqtane-specific base class.
This is because certain properties such as
Name
will only be known to Oqtane if the implementation inherits from these base classes.This also adds a lot of baggage to each control and container. For example:
ThemeBase
and incl. loads of overloads ofNavigateUrl(...)
each with minor variationsBUT: my understanding of good architecture prefers composition,
which is what I would like to encourage in various docs. But as of now, this is not possible.
My recommendation is that we promote Composition. This requires the following changes - for example for containers:
IContainer
- or we could enhance the existingIContainerControl
Name
Note: ATM there is something similar on the
IThemeControl
, but this should not be usedPaneNames
which are simply not necessary on most components or even Containers.Resources
which again may not be relevant to the implementation of most controls, so allowing that on a separate optional interface likeIHasResources
or something would make much more sense.Anything else?
Would really appreciate if we could change this, to promote good practices and ensure long term stability of the API without cluttering the code.
I would also contribute the change if it's approved.
The text was updated successfully, but these errors were encountered: