In the sample project, Mark DiFranco creates a class that provides the user's current speed. He applies the concepts of Single Responsibility and dependency inversion to keep the class small, and independent of other classes.
- [Instructor] Let's look at implementing…one of these consumers.…We'll start with the Speed Consumer.…(computer keystrokes)…We can create a class called SPD Location Speed Provider.…(computer keystrokes)…This class will take a location…and determine the speed and pass it along.…We'll start this class, similarly,…by defining a protocol,…SPD Location Speed Provider…(computer keystrokes)…I'll define a class right below it,…SPD Default Location Speed Provider.…
And, we can extend this class…to conform to our protocol.…(computer keystrokes)…This class will need locations,…so it'll use the Location Provider Class to receive them.…Ladder property for the SPD Location Provider.…Once again, we can update our constructor…to pass in this property.…(computer keystrokes)…And, we'll set it on, ourself.…
Now that we have property,…we can add a line below to add ourself as a consumer.…This is creating a compiler error…because we haven't conformed to the right protocol.…Let's do that in an extension, near the bottom of the file.…(computer keystrokes)…
- Why write unit tests?
- What is dependency injection?
- Using protocols to help with tests
- Handling external dependencies
- Anatomy of a test case
- Writing tests
- Analyzing code coverage
- Visualizing test results
- Writing and extending UI tests
Skill Level Intermediate
1. Dependency Injection
2. Using Protocols
3. Writing Tests
4. UI Tests
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.