-
Notifications
You must be signed in to change notification settings - Fork 285
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
Implement interfaces and abstract classes #1783
Comments
@faustbrian @kristjank @vasild
I'm for approach 2 because it has the least friction. The tests in the modules already reference, what would be,the interface names; when writing concrete implementations, we can adopt the naming pattern |
The least intrusive one for now is approach 2 but there is a far bigger issue with how types are currently done, which is why I in your initial types PR said it is OK for now but will need changes later on. With how types are currently introduced and used all packages have to know about each others existents and exactly know which package provides the concrete implementations. The whole point of how packages have been structured so far is that this doesn't have to be the case, they only need to have the Packages are bound to the container so plugins don't have any use for each other anyways as the instances that are useful to them are created in the These kinda structural issues need to be addressed first as we otherwise defeat the purpose of the plugin system, which is to easily swap out components without having to spend days replacing code in another 20 packages. The general rule is that plugins should not require anything but |
True, with pure JS, only having a dependency on The alternative approach which you initially suggested @faustbrian , would be to create a "types" module alongside each module. While this is the de-facto way of supplying types for modules migrated to TS, the additional overhead of maintaining each one separately, creating new build/CI configs(ableit one-off), and having to go through NPM is sort of a pain in the ass. Ideally, we could leverage a build system that can be able to package up the The single interfaces package with namespaces was my suggestion for overcoming the circular dependency issue and the NPM & additional configs overhead in one solution. While it does have its drawbacks,
To address point 1 & 2, we set the precedent that, if a given module is not a core module(meaning, it's optional, or given that module is absent the code still runs fine) then don't introduce your types into the |
I don't think there is that much more overhead for maintaining type packages as they should rarely change in the future and if they do it won't be anything major. Versioning and publishing them is also a negligible amount of work as that will be automated. A plugin system rework is scheduled for 3.0 as I will be introducing a lot of breaking changes and resolve a lot of issues that were caused by how JavaScript works and enforce stricter contracts that need to be satisfied by plugins. I am not home until the 1st of January but when I am back I will review a few things and look at what approach would be the simplest for now. If you want you can work on the interfaces solution and I will review it when I am back but no guarantee that it will get merged. |
Fair enough, my concern w/ the types package is that you're essentially forcing all changes(whether permanent or temp) to go through npm. From a development standpoint, this degrades the experience as modules cannot see any local changes to the types w/o having to first publish them to npm. |
They would be managed in the same repository. I would restructure the repository to contain 3 folders that are managed by lerna as
|
So, I thought about it some more, and even in their own types modules, you'd still have the circular dependency problem if your interfaces need to reference each other(method parameters or instance properties). If they're all in a single module, they can all see each other so it's all good, but if they're in different modules, the types modules would have to have dependencies on each other and you run into the same problem, introducing a circular dependency among the types modules. The only way that would work is if the dependencies are realized(so |
At the moment we have classes that are named like
ConnectionInterface
, using anInterface
suffix to indicate that they have implementation expectations.Those classes are actually
abstract
classes and should be refactored to behave like one. There are a few exceptions which are or should actually beinterfaces
that are implemented by other classes instead of extending anabstract
class.The text was updated successfully, but these errors were encountered: