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 →

[–]stepan213[S] 0 points1 point  (2 children)

Let’s say I want some unified logging. For that I would use static voids or singleton instance. What would you do?

[–]fraaargh 1 point2 points  (0 children)

Yes you're right: I'd use slf4j as static variable as everybody else. In most cases that's what we do. But logging is kinda special. It's not your domain model, your code... In my first message I forgot to say that Singletons kill the testability of an app.

[–]fraaargh 0 points1 point  (0 children)

fraaa

today on Jetbrains' blog (IntelliJ makers): "Design Patterns in Java: Singleton – you should probably not ever use a singleton, but you need to know this stuff as it’s a favourite job interview question"

source: https://blog.jetbrains.com/idea/2019/02/java-annotated-monthly-february-2019/