oop - Qu'est-ce que l'inversion de contrôle

Mots clés : oopdesign-patternsinversion-of-controloop

meilleur 2 Réponses oop - Qu'est-ce que l'inversion de contrôle

vote vote

100

public class TextEditor {      private SpellChecker checker;      public TextEditor() {         this.checker = new SpellChecker();     } } 
public class TextEditor {      private IocSpellChecker checker;      public TextEditor(IocSpellChecker checker) {         this.checker = checker;     } } 
SpellChecker sc = new SpellChecker(); // dependency TextEditor textEditor = new TextEditor(sc); 
vote vote

89

print "enter your name" read name print "enter your address" read address etc... store in database 
when the user types in field a, store it in NAME when the user types in field b, store it in ADDRESS when the user clicks the save button, call StoreInDatabase 

Questions similaires