From the course: Spring: Design Patterns
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
The Command pattern
- [Instructor] The Command pattern is another one of these design patterns that exists in the Spring framework we don't use a lot that are behavior based. In the Spring framework there's really two distinct use cases. First, it's seen with Runnable instances. Things like the CommandLineRunner, where you're going to execute a Runnable command from the base class itself. The second use case that we see is all the more often seen, and that's in our MVC layer. And there's actually an AbstractCommandController that you can use in Spring MVC that implements this command pattern. And the idea here is that in an MVC world, often you're going to execute these commands against controls, and you don't want to manipulate the individual controls. That's going to lead us into what the pattern actually is. The whole gist of the command pattern is that it provides an abstraction layer for these request processing scenarios. Think about a shopping cart. You have a very common pattern that you go…
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.