Skip to content
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

Reducing JavaDefaultNameProvider instances #13

Open
BenjaminKlatt opened this issue Jan 1, 2014 · 0 comments
Open

Reducing JavaDefaultNameProvider instances #13

BenjaminKlatt opened this issue Jan 1, 2014 · 0 comments

Comments

@BenjaminKlatt
Copy link
Contributor

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.

jamopp-profiling-javadefaultnameprovider-instances

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant