[Effective Java] Item 5 – Prefer dependency injection to hardwiring resources

Published by

on

Summary

  • Classes that depends on underlying resources are not appropriate to be static utility class or singleton class.
    • For example, the dictionary can be different maps per usage, but we cannot declare new classes every time per purpose.
  • Pass the resource into the constructor when creating a new instance

Leave a comment