Command pattern is a data determined propose pattern and falls under behavioural pattern group. A request is wrapped under an object as command and passed to invoker object. Invoker object looks for the correct object which can handle this command and passes the command to the matching object which executes the command.
We have formed an interface Order which is acting as a command. We have formed a Stock class which acts as a request. We have real command classes Buy Stock and Sell Stock implementing Order line which will do definite command processing. A class Broker is created which acts as an invoker entity. It can take and place preparation.
Broker entity uses command pattern to recognize which object will implement which command based on the type of command. CommandPatternDemo, our demo class, will use Broker class to express charge pattern.
Create a command interface.
Create a request class.
Create concrete classes implementing the command interface.
Create command invoker class.
Use the Broker class to take and perform information.
Verify the output.
Design Patterns Related Interview Questions
|Java Script Interview Questions||AJAX Interview Questions|
|Graphic Design Interview Questions||Adobe Indesign Interview Questions|
|Java-Multithreading Interview Questions||Database Design Interview Questions|
|Compiler Design Interview Questions||CSS Advanced Interview Questions|
|Java Design Patterns Interview Questions||Hardware design Interview Questions|
|Material Design Lite Interview Questions||Object Oriented Analysis and Design Interview Questions|
|Standard Template Library (STL) Interview Questions|
Design Patterns Tutorial
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.