Casper Schmidt Wandahl-Liper , thanks for the suggestion. I am agree with you that implementing classes have extra responsibility to register themselves, however I kept it that way. LoggerFactory is designed as a static class. In this context, if I use dependency injection (constructor) in LoggerFactory , that object itself becomes a proxy i.e; the constructor just takes the parameter & assigns it to the static variable (map or whatever it is) in the class LoggerFactory. After the static variable is initialized, you can use the getInstacnce method as shown in the code to get correct logger instance. This way of creating a proxy object which does not get used later did not make a lot of sense. Also if you want to shift the responsibility of registering the logger instances to some other class, that class has to manage the mapping between registration key vs the .class class instances. How can it do so — by using some if else logic to assign a.class for a particular class instance to a reg key or by using a hacky class naming mechanism? I feel it’s all trade off, but I went ahead with the simplified implementation so that developers understand the code well.

Written by

Deep discussions on problem solving, distributed systems, computing concepts, real life systems designing. Developer @PayPal. https://in.linkedin.com/in/kousikn

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store