Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Command pattern
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Overview== The command<ref name="GoF">{{cite book |author=Erich Gamma |author2=Richard Helm |author3=Ralph Johnson |author4=John Vlissides|title=Design Patterns: Elements of Reusable Object-Oriented Software|year=1994|publisher=Addison Wesley|isbn=0-201-63361-2|pages=[https://archive.org/details/designpatternsel00gamm/page/233 233ff]|url-access=registration|url=https://archive.org/details/designpatternsel00gamm/page/233}}</ref> design pattern is one of the twenty-three well-known ''[[Design Patterns|GoF design patterns]]'' that describe how to solve recurring design problems to design flexible and reusable object-oriented software, that is, objects that are easier to implement, change, test, and reuse. Using the command design pattern can solve these problems:<ref>{{cite web |title=The Command design pattern - Problem, Solution, and Applicability |url=http://w3sdesign.com/?gr=b02&ugr=proble |access-date=2017-08-12 |website=w3sDesign.com |archive-date=2020-09-23 |archive-url=https://web.archive.org/web/20200923124858/http://w3sdesign.com/?gr=b02&ugr=proble |url-status=dead }}</ref> * Coupling the invoker of a request to a particular request should be avoided. That is, hard-wired requests should be avoided. * It should be possible to configure an object (that invokes a request) with a request. Implementing (hard-wiring) a request directly into a class is inflexible because it couples the class to a particular request at compile-time, which makes it impossible to specify a request at run-time. Using the command design pattern describes the following solution: * Define separate (command) objects that encapsulate a request. * A class delegates a request to a command object instead of implementing a particular request directly. This enables one to configure a class with a command object that is used to perform a request. The class is no longer coupled to a particular request and has no knowledge (is independent) of how the request is carried out. See also the UML class and sequence diagram below.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Command pattern
(section)
Add topic