-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Separate object creation from non-trivial operations. #10542
Comments
In terms of concrete steps, the following should be done for all classes in the code base, with an initial preference toward those with
It may make sense to be a bit more granular about it:
Splitting phases 1 & 2 could happen as well, but that isn't as important. There is also the question of how to make sure we do not regress. It may make sense to add a test that verifies that all constructor bodies are empty. That should be doable without much parsing complexity. It would require that all classes be updated to move everything out of the constructor body and into an |
We'll try this out with the upcoming "env discovery" work. |
We did this: #10542 (comment), closing. |
Constructors really shouldn't do anything more than trivial setting of state. However, we have quite a few classes with non-trivial constructors. (For example, of those with
@injectable
applied, there are at least 96. See #10454.) This adds complexity that makes it harder to understand what is happening when the extension is starting up, much less carefully controlling and adapting activation.To address this, we should do the following:
The phases would be something like this:
A hard separation between these phases makes it much easier to understand what is going on and to divide up extension activation along horizontal layers. Note that the phases easily map onto methods. An interface (for discussion purposes only) could look like one of the following:
(Note that the problem has been addressed for some classes, though with various different solutions. So this is also the right time to apply a consistent approach to how we tackle the problem.)
Of particular interest are classes with any of the following characteristics:
@injectable
applied:initialize()
,register*()
,activate()
,start()
Relative to those classes, we should consolidate on a simple initialization "interface" that we can use consistently during extension activation. It should also make it easy to identify the level of complexity of a class's initialization.
The text was updated successfully, but these errors were encountered: