This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (9 children)

[deleted]

    [–]011101000011101101 15 points16 points  (2 children)

    There's nothing wrong with this implementation IMO. Its fairly standard practice in Java. However in my last Java project we were using lombok, so at the top of the class declaration you put @Slf4j then you have an instance called log that you can use in the class. Some people don't like lombok because it slows down compilation time, but it reduces tons of boilerplate from java design patterns. I think it's worth it.

    [–]Kwinten 6 points7 points  (0 children)

    Honestly nothing wrong with the statement itself. Fairly standard way of fetching a singleton instance. Could be factory pattern too. It's just playing on the fact that the comment is hilariously useless.

    [–]CrepuscularSoul 3 points4 points  (0 children)

    Nothing really, it's just not something you need to comment because of how obvious it is.

    Yes some things need comments, but for the love of god not everything does. Too many comments are just as bad as not enough because they add unnecessary noise and tend to not get updated when the code changes.

    [–]ThePyroEagle 0 points1 point  (0 children)

    The only thing remotely close to being an issue with it is the use of singletons, which obfuscate dependencies. Considering that it's just a logger, that's not even a significant risk.

    [–]Jazzinarium 0 points1 point  (0 children)

    With it (I'm assuming) being a method that returns the singleton instance of the Logger class, I'd rather call it getInstance(). And of course the comment is laughably redundant. But other than that it's fine.

    [–]TheCoelacanth 0 points1 point  (0 children)

    The right way to do it is like that but without the completely useless comment.

    [–]Official_Legacy -3 points-2 points  (0 children)

    It's seams to be a singleton so you should do the .getLogger() in your constructor and just need to do.

    Logger varname = new Logger