Join Elisabeth Robson for an in-depth discussion in this video Using the exercise files, part of Foundations of Programming: Design Patterns.
Unlike some of the other Lynda.com courses, all the exercise files provided in this course are free for all viewers. I have them downloaded to my desktop, and they're in a folder called Exercise Files. I'm currently on a Mac here, but it doesn't matter if you use a different operating system. Inside the folder, we have a source folder. And then chapter folders that correspond to the packages containing the code. Inside the chapter folders, you'll find the files for the design pattern we'll be working with in that chapter.
We'll point the files out to you at the time you need them, showing you the path to the file location. These files are all for convenience. They're not required, but they might make things a little easier as you follow along. All these examples are taken from our book Head First Design Patterns. If you have that book you can follow along there too. We've made a few modifications for the course, but much of the code will be exactly the same. I'll be using Eclipse to demonstrate and run each example. If you're new to Eclipse, and you want to give it a try, you can find an introduction to Eclipse in the course, Java Essential Training.
The examples are all in the design patterns package, and each design pattern has its own subpackage name, like strategy, for the strategy pattern. For a couple of the examples, we'll provide more than one version of the code. So you'll find sub-folders within the pattern folders for those. If you don't know Java, and you're using a different object-oriented language, don't worry because you can still follow along. The code examples here are primarily to demonstrate the principles and patterns we cover in the course. And the patterns can be used with any object-oriented language.
The examples we've done demonstrate depend on Java 6, so any IDE that supports Java 6 or higher will work.
- What are design patterns?
- Encapsulating code that varies with the strategy pattern
- Setting behavior dynamically
- Implementing the observer pattern
- Creating chaos with inheritance
- Extending behavior with composition
- Dealing with multithreading and the singleton pattern
- Revising the design for a state machine
- Encapsulating iteration with the collection pattern
- Encapsulating object creation with the factory method pattern