Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
GetLevel getLevel = new GetLevel();
getLevel.getLevel(new IGetLevelable(){
private int level = 1;
public int getLevel() {
return level;
}
}
At least it's verbose. When you look at that code you instantly know that it gets a level
/s -
@PaulTheSaltyDev It didn't require a class as argument. The class itself was just used as a kind of namespace. But only for one method:
new GetLevel().getLevel(<Whatever arguments>);
- First: It's ugly
- Second: You create a useless instance of GetLevel which get garbage collected right after that.
I guess he wasn't much into Java, bc when I showed him the static aproach, he at least removed the unnecessary instance.
So it's *just*: GetLevel.getLevel(<Whatever arguments>); -
I do this sometimes when I anticipate that this function could be really complex and I would need other functions down the line in this class. Sure there is an overhead here in some cases. But premature optimisation is the root of all evil.
Related Rants
U've seen one dev creating Java-Classes like 'GetLevel' which contain only one method that is called 'getLevel'. And it wasn't even a static method.
rant
wtfisthis
naming
java
wk99