You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each instance of JavaDefaultResolverDelegate indirectly instantiates a new JavaDefaultNameProvider as an instance of a IJavaNameProvider by calling JavaMetaInformation.createNameProvider(). While the delegate uses a single instance of JavaMetaInformation, a new instance of the JavaDefaultNameProvider is created in the createNameProvider() method.
With the ArgoUML based case study performed in the SPLevo / KoPL project, this leads to more then 400,000 not necessary instances of this class. (Note, the JProfiler screenshot provided below is made during the processing. The final result is not possible at the time of writing, because JaMoPP does not finish in a reasonable time yet.
Code Review Results
IJavaNameProvider provides only the method getNames(), and JavaDefaultNameProvider's implementation is status-independend, threadsafe and does not require a fresh instance with for every JavaDefaultResolverDelegate, or even with each call to JavaMetaInformation.createNameProvider()
Recommended Refactoring
A lightweight refactoring to prevent the creation of all these unnecessary instances is to change the createNameProvider() method to always return the same JavaDefaultResolverDelegate instance with each create call.
The text was updated successfully, but these errors were encountered:
Current Implementation
Each instance of JavaDefaultResolverDelegate indirectly instantiates a new JavaDefaultNameProvider as an instance of a IJavaNameProvider by calling JavaMetaInformation.createNameProvider(). While the delegate uses a single instance of JavaMetaInformation, a new instance of the JavaDefaultNameProvider is created in the createNameProvider() method.
With the ArgoUML based case study performed in the SPLevo / KoPL project, this leads to more then 400,000 not necessary instances of this class. (Note, the JProfiler screenshot provided below is made during the processing. The final result is not possible at the time of writing, because JaMoPP does not finish in a reasonable time yet.
Code Review Results
IJavaNameProvider provides only the method
getNames()
, and JavaDefaultNameProvider's implementation is status-independend, threadsafe and does not require a fresh instance with for every JavaDefaultResolverDelegate, or even with each call to JavaMetaInformation.createNameProvider()Recommended Refactoring
A lightweight refactoring to prevent the creation of all these unnecessary instances is to change the createNameProvider() method to always return the same JavaDefaultResolverDelegate instance with each create call.
The text was updated successfully, but these errors were encountered: