Resource Google Guice example project (Dependency Injection)

Discussion in 'Spigot Plugin Development' started by Vengine, Apr 26, 2021.

  1. Vengine

    Vengine Previously SkillCode

    Code design is a topic that a lot of people don't pay attention to (including me in the past). One of the currently best known and most efficient design patterns is Dependency Injection (DI).

    DI is used to resolve dependencies between classes in order to optimize the code for unit tests, among other things. To use DI in the best possible way, I advise to use a DI framework (it is not absolutely necessary),
    there are several of them. One of the best known is the Spring Framework, but it would be much too big and complex for a Minecraft plugin, as it includes many other things.
    I personally decided to use the Guice Framework, because it covers the full range of functions of most other DI frameworks and is relatively small in size.
    To get a better introduction to this topic, I created a small example project and published it on GitHub.

    • Like Like x 2
    • Useful Useful x 2
  2. Nice, can be useful for very big project
  3. Neither "too big" or "too complex" are correct, you meant irrelevant.
  4. isn't this like lombok?
  5. Vengine

    Vengine Previously SkillCode

    no, Lombok just generates getters/setters/constructors for you
  6. Vengine

    Vengine Previously SkillCode

    yeah you're right, I have expressed myself incorrectly.