-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add docs for module vs package #19
Comments
Initial thoughts on this:
|
More thoughts: The idea behind modularization is to make it easy for us to split up the work and more easily maintain things. The separation between packages/modules is mainly based on the single responsibility principle. As I see it, anything related to onboarding should be in an onboarding package/module. I'm not sold on whether onboarding should be a toggleable module or not. Users don't need the ability to turn it off and on and support doesn't really need that capability either. Regardless, unless there is a technical reason why we can't include a certain bit of code in a module if the code is related to that module's single purpose, then I say we keep all those things together as long as we can follow reasonable architectural principles. For example, one of those technical reasons might be that we need JS as an NPM package. When discussing just data and PHP code, I don't think we necessarily need to split things out further. I think we should probably come up with some convention for the organization of code so it is clear what always loads vs. what loads when the module is enabled. We do have examples in other modules where we have code that always loads vs. what is toggleable. For example, the e-commerce module can be toggled, but we do have some code that handles automatically adding PayPal partner attribution codes to outgoing PayPal requests. Since that is directly related to e-commerce, it makes sense to keep it in that module. We also have other modules that handle plugin activation/deactivation hooks and upgrade processes outside of the toggleable aspect of the module. Ultimately, if we need the ability to toggle something, it should be a Newfold module. If we don't, just a Composer package will do. If we need a hybrid, then a Newfold module with the ability to load some code all the time is the way to go. |
A module (the always loaded portion) would register data into the container and other modules can read what they need from the container. We'll need to structure and name things well in the container, but that gives the module control over naming/re-naming options, etc. as needed. The container can hold data, factories, services, and callback functions for computed data (https://github.com/newfold-labs/container). Each module that depends on the data should have its own safeguards should a specific property not be available in the container. We should also be careful to leverage a shared interface/API for injected dependencies. In this way, we have loose coupling between the modules. |
Newfold Modules are a fundamental component of Newfold's development framework. They are essentially Composer packages that enable the implementation of various features and functionalities within Newfold plugins. Modules can be categorized into three distinct types based on their intended usage. 1. Toggleable ModuleA Toggleable Module is designed to be flexible, allowing it to be activated or deactivated based on specific conditions. This type of module can be toggled on and off by either customers or support staff by setting an option, transient, query parameter, or via the user interface (UI). It follows a common registration process and executes its code only as part of the callback function provided during the registration. Usage Guidelines:
2. Non-Toggleable ModuleNon-Toggleable Modules, as the name suggests, cannot be turned on or off dynamically. These modules are designed to serve as Composer packages without the need for intricate registration processes. They do not place their code within the register function and can be considered as standalone utility packages. Usage Guidelines:
3. Hybrid ModulesHybrid Modules offer a high degree of flexibility but come with potential risks and complexities. These modules register themselves using the standard registration process, including the execution of part of their code within the callback function provided during registration. However, they can also contain code outside of the register function. Usage Guidelines:
Best Practices
|
Detail when we need a module vs simply a package.
The text was updated successfully, but these errors were encountered: