Common Mistakes When Using the Command Pattern and How to Avoid Them

Pattern Languages of Programs(2020)

引用 1|浏览4
暂无评分
摘要
ABSTRACTCommand, is a behavioral pattern from the Gang of Four catalog that allows us to structure an application with respect to primitive actions that can be easily managed and executed. The main idea is to decouple the objects that invoke actions from the objects that know how to perform them, by encapsulating everything that is needed for executing the actions in corresponding command objects. The application can comprise different classes of command objects that realize different actions. The different classes of command objects implement the same interface. Therefore, command objects can be passed as parameters to other objects that use them to execute the respective actions, without knowing how this is actually done. This paper revisits the Command pattern, focusing on the configuration of command objects, when the data that are needed for the execution of the actions become available as soon as the actions should be executed. In this case, it is not clear which class is responsible for configuring the command objects and how this should be done. The paper reports common mistakes when dealing with this problem, as anti-patterns, observed during the project of a software engineering course. The observed mistakes invalidate the benefits of the Command pattern because the invoking objects are explicitly or implicitly coupled with the concrete classes of command objects that realize the different actions. The paper further introduces a pattern that deals with the problem.
更多
查看译文
AI 理解论文
溯源树
样例
生成溯源树,研究论文发展脉络
Chat Paper
正在生成论文摘要