-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Adding initialization-on-demand idiom and noninstantiable class instead of interface constant idiom #532
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
Conversation
In the Singleton example IvoryTower demonstrates eagerly initialized instance. In this pull request you have changed it implement Initialization-on-demand holder idiom. However, this has already been demonstrated in InitializingOnDemandHolderIdiom. |
The second change concerning CustomerSchemaSql doesn't add any value since variables in interfaces are static and final by default. |
I know they are static and final by default, the problem with the interface is that somebody can implement from it. We don't want that. Those classes were not designed to be instantiated. I am enforcing noninstantiability by using this idiom:
|
Ok, after reading more about the constant interface idiom I tend to agree that it is better style to declare final class instead. I wonder if this idiom has been used elsewhere in the codebase? If you update the pull request and comment on this thread I can accept it. |
Added a little description, thanks :) |
Added a few more changes, found that several java classes were using references to implementations instead of using abstractions/interfaces. Please review :D @iluwatar |
@leogtzr looks good. Still the changes concerning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iluwatar done, I have reverted the changes for |
@leogtzr thank you for the improvements! |
Adding noninstantiable class instead of interface constant idiom.