the singleton pattern the main criticism of the singleton pattern is that it is just pretty way to get global statewhich is one of the things you want to avoid when writing programs one of the reasons why you want to avoid global state is that code in one part of your project may alter the global state and cause unexpected results in completely unrelated piece of code that saidwhen you have parts of project that do not affect the execution of your codelike loggingit is acceptable to use global state other places where global state may be used are in cachingload balancingand route mapping in all these casesinformation flows in one directionand the singleton instance itself is immutable (it does not changeno part of the program attempts to make change in the singletonand as such there is no danger of one part of project interfering with another part of the project because of the shared state there you have it--you have discovered your first design patternwhich is called the singleton pattern congratulationsexercises implement your own logger singleton how would you create logger using the singleton pattern(creditinspiration for the singleton pattern code template was sparked by the singleton pattern implementation on readthedocs io/en/latest/singleton html cc-by-sa