mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 04:59:24 +00:00
Resolves checkstyle errors for delegation dependency-injection dirty-flag double-buffer double-checked-locking double-dispatch (#1068)
* Reduces checkstyle errors in delegation * Reduces checkstyle errors in dependency-injection * Reduces checkstyle errors in dirty-flag * Reduces checkstyle errors in double-buffer * Reduces checkstyle errors in double-checked-locking * Reduces checkstyle errors in double-dispatch
This commit is contained in:
committed by
Ilkka Seppälä
parent
01e489c77b
commit
f2c91eb836
@@ -31,25 +31,26 @@ import com.google.inject.Injector;
|
||||
* implements so called inversion of control principle. Inversion of control has two specific rules:
|
||||
* - High-level modules should not depend on low-level modules. Both should depend on abstractions.
|
||||
* - Abstractions should not depend on details. Details should depend on abstractions.
|
||||
* <p>
|
||||
* In this example we show you three different wizards. The first one ({@link SimpleWizard}) is a
|
||||
* naive implementation violating the inversion of control principle. It depends directly on a
|
||||
*
|
||||
* <p>In this example we show you three different wizards. The first one ({@link SimpleWizard}) is
|
||||
* a naive implementation violating the inversion of control principle. It depends directly on a
|
||||
* concrete implementation which cannot be changed.
|
||||
* <p>
|
||||
* The second and third wizards({@link AdvancedWizard} and {@link AdvancedSorceress}) are more flexible.
|
||||
* They do not depend on any concrete implementation but abstraction. They utilizes Dependency Injection
|
||||
* pattern allowing their {@link Tobacco} dependency to be injected through constructor ({@link AdvancedWizard})
|
||||
* or setter ({@link AdvancedSorceress}). This way, handling the dependency is no longer the wizard's
|
||||
* responsibility. It is resolved outside the wizard class.
|
||||
* <p>
|
||||
* The fourth example takes the pattern a step further. It uses Guice framework for Dependency
|
||||
*
|
||||
* <p>The second and third wizards({@link AdvancedWizard} and {@link AdvancedSorceress}) are more
|
||||
* flexible. They do not depend on any concrete implementation but abstraction. They utilizes
|
||||
* Dependency Injection pattern allowing their {@link Tobacco} dependency to be injected through
|
||||
* constructor ({@link AdvancedWizard}) or setter ({@link AdvancedSorceress}). This way, handling
|
||||
* the dependency is no longer the wizard's responsibility. It is resolved outside the wizard
|
||||
* class.
|
||||
*
|
||||
* <p>The fourth example takes the pattern a step further. It uses Guice framework for Dependency
|
||||
* Injection. {@link TobaccoModule} binds a concrete implementation to abstraction. Injector is then
|
||||
* used to create {@link GuiceWizard} object with correct dependencies.
|
||||
*/
|
||||
public class App {
|
||||
|
||||
/**
|
||||
* Program entry point
|
||||
* Program entry point.
|
||||
*
|
||||
* @param args command line args
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user