Which statement describes the Command pattern?

Prepare for the Object-Oriented Programming Test with flashcards and multiple choice questions. Each question comes with hints and explanations to enhance understanding. Master OOP concepts and succeed in your exam!

Multiple Choice

Which statement describes the Command pattern?

Explanation:
The Command pattern is about turning a request into a stand-alone object that can be passed around, stored, or undone. This object usually provides an execute method, and often an undo method, which allows the same command to be invoked by different parts of a system without those parts needing to know how the action is carried out. Because the sender of the command only interacts with the command object and not with the receiver, the two are decoupled, making it easy to queue commands, log them, or implement undo/redo functionality. The statement highlighting encapsulating a request as an object with execute and undo, while decoupling sender and receiver, captures this idea precisely. The other descriptions describe different ideas—direct method calls imply tight coupling, data persistence focuses on storage, and lazy initialization targets performance optimization—not the command pattern.

The Command pattern is about turning a request into a stand-alone object that can be passed around, stored, or undone. This object usually provides an execute method, and often an undo method, which allows the same command to be invoked by different parts of a system without those parts needing to know how the action is carried out. Because the sender of the command only interacts with the command object and not with the receiver, the two are decoupled, making it easy to queue commands, log them, or implement undo/redo functionality. The statement highlighting encapsulating a request as an object with execute and undo, while decoupling sender and receiver, captures this idea precisely. The other descriptions describe different ideas—direct method calls imply tight coupling, data persistence focuses on storage, and lazy initialization targets performance optimization—not the command pattern.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy