public class TextEditor {
   private SpellChecker spellChecker;

   public TextEditor(SpellChecker spellChecker) {
      this.spellChecker = spellChecker;
   }
}

Spellchecker 被注入到 TextEditor 的建構元裡面

The code is cleaner with the DI principle and decoupling is more effective when objects are provided with their dependencies.

results matching ""

    No results matching ""