6

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.

Comments
  • 1
    *vomiting*
    *vomiting so much*
    *still vomiting*
  • 0
    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
  • 0
    @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>);
  • 1
    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.
Add Comment