From the course: Java Design Patterns: Behavioral Part 1
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Implementing a successor chain - Java Tutorial
From the course: Java Design Patterns: Behavioral Part 1
Implementing a successor chain
- [Instructor] In this example, I'm going to implement a successor chain and an app that opens documents. So a successor chain takes an argument, and it checks if it can be handled by the first handler in the chain. And if it can't, it passes it on to the next handler. And that handler checks if it can handle it. And if it can't, it passes it on again, and so on until it finds a handler that can handle the request. So this is going to be a simple app for opening documents. So it might be used with a user interface where a user clicks on a button to open a file, and the type of file that opens might depend on the context in the user interface. So we don't know at the moment which type of file they might open. So the first thing I'm going to do is I'm going to create a class for handling the documents. So in my ID, I'm going to create a new class, I'm just going to right click on the Java directory, and go to new Java class.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.