Skip to content

Commit

Permalink
Add LO-DI
Browse files Browse the repository at this point in the history
  • Loading branch information
damithc committed Sep 12, 2016
1 parent c31fdd6 commit cf3f1f2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Binary file modified doc/Diagrams.pptx
Binary file not shown.
17 changes: 17 additions & 0 deletions doc/LearningOutcomes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down Expand Up @@ -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. <br>
<img src="images/DependencyInjection.png">
* Implement the `StorageStub` to ignore calls to the `save` method.
Update the `LogicTest` to work with the `StorageStub` instead of the actual `StorageFile` object.

------------------------------------------------------------------------------------------------------

Binary file added doc/images/DependencyInjection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cf3f1f2

Please sign in to comment.