diff --git a/doc/Diagrams.pptx b/doc/Diagrams.pptx index a796564d8..6e9071e2f 100644 Binary files a/doc/Diagrams.pptx and b/doc/Diagrams.pptx differ diff --git a/doc/LearningOutcomes.md b/doc/LearningOutcomes.md index 5a8b4b39d..1cb2e4b01 100644 --- a/doc/LearningOutcomes.md +++ b/doc/LearningOutcomes.md @@ -8,6 +8,7 @@ After studying this code and completing the corresponding exercises, you should 1. [Use abstract classes/methods `[LO-Abstract]`](#use-abstract-classesmethods-lo-abstract) 1. [Follow Liskov Substitution Principle `[LO-LSP]`](#follow-liskov-substitution-principle-lo-lsp) 1. [Use Java-FX for GUI programming `[LO-JavaFx]`](#use-java-fx-for-gui-programming-lo-javafx) +1. [Use Dependency Injection `[LO-DI]`](#use-dependency-injection) @@ -89,3 +90,19 @@ Covered by `[LO-Polymorphism]` ------------------------------------------------------------------------------------------------------ + +## Use Dependency Injection `[LO-DI]` + +#### Exercise: Facilitate injecting a StorageStub + +* Note how `Logic` class depends on the `StorageFile` class. This means when testing the `Logic` class, + our test cases executes the `StorageFile` class as well. What if we want to test the `Logic` class without + getting the `StorageFile` class involved? +* Now, change the implementation as follows so that we can inject a `StorageStub` when testing the `Logic` + class.
+ +* Implement the `StorageStub` to ignore calls to the `save` method. + Update the `LogicTest` to work with the `StorageStub` instead of the actual `StorageFile` object. + +------------------------------------------------------------------------------------------------------ + diff --git a/doc/images/DependencyInjection.png b/doc/images/DependencyInjection.png new file mode 100644 index 000000000..562ae6b6a Binary files /dev/null and b/doc/images/DependencyInjection.png differ