User Tools

Site Tools


patterns:parameter_object

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
patterns:parameter_object [2013-07-23 16:06] christianpatterns:parameter_object [2021-10-18 22:24] (current) – +++ restored +++ christian
Line 16: Line 16:
 ===== Problem ===== ===== Problem =====
  
-  * Often there are methods which take a large number of input parameters. This makes using them cumbersome and the code less readable. +  * Often there are methods which take a large number of input parameters. This makes using them cumbersome and the code less readable. See [[anti-patterns:Long Parameter List]] and [[anti-patterns:Data Clumps]]. Sometimes this is also a sign of [[anti-patterns:Primitive Obsession]]
-  * A second problem is the evolution of method signatures. There are circumstances where there is the chance that in the future further parameters will be added without all the users of the method needing the new parameter. [[glossary:Events]] are an example for that. Normally a change to a method parameter technically requires every caller to change also independent of whether the caller is logically required to change.+  * A second problem is the evolution of method signatures. There are circumstances where there is the chance that in the future further parameters will be added without all the users of the method needing the new parameter. [[glossary:Events]] are an example for that. Normally a change to a method parameter technically requires every caller to change also---independent of whether the caller is //logically// required to change. This leads to [[glossary:ripple effects]] and [[glossary:shotgun surgery]].
  
-===== Structure =====+===== Solution ===== 
 + 
 + 
 +==== Structure ==== 
 + 
 +==== Dynamics ==== 
 + 
 +==== Implementation Hints ==== 
 + 
 +==== Variations ====
  
-===== Variations ===== 
  
 ===== Origin ===== ===== Origin =====
  
 {{page>resources:Arguments and Results#reference}} {{page>resources:Arguments and Results#reference}}
 +
  
 ===== Advantages ===== ===== Advantages =====
Line 36: Line 45:
   * [[principles:More Is More Complex|MIMC]]: An additional class is introduced   * [[principles:More Is More Complex|MIMC]]: An additional class is introduced
   * [[principles:Keep It Simple Stupid|KISS]]: Calling the method is more complex as the parameter object has to be instantiated    * [[principles:Keep It Simple Stupid|KISS]]: Calling the method is more complex as the parameter object has to be instantiated 
 +
  
 ===== Relations to Other Patterns ===== ===== Relations to Other Patterns =====
  
-===== Pattern Collections =====+==== Generalizations ==== 
 + 
 +==== Specializations ==== 
 + 
 +  * [[Selector Object]] 
 +  * [[Curried Object]] 
 + 
 +==== Alternative Patterns ==== 
 + 
 +==== Complementary Patterns ==== 
 + 
 +==== Pattern Collections ==== 
 +{{page>collections:Patterns for Arguments and Results#Box}} 
  
 ===== Examples ===== ===== Examples =====
Line 45: Line 68:
 ==== Example 1: Event Args ==== ==== Example 1: Event Args ====
  
-A typical usage of this pattern is the groping of parameter in [[glossary:events]]. Some events carry large amounts of context data. Furthermore modifying the signature of an event causes large ripple effects as they are typically used on the interface to other subsystems, layers, etc. and there is an unknown and probably large amount of users of the event.+A typical usage of this pattern is the grouping of parameter in [[glossary:events]]. Some events carry large amounts of context data. Furthermore modifying the signature of an event causes large ripple effects as they are typically used on the interface to other subsystems, layers, etc. and there is an unknown and probably large amount of users of the event.
  
   * In .NET there is the class [[http://msdn.microsoft.com/de-de/library/vstudio/system.eventargs.aspx|System.EventArgs]] and its descendants.   * In .NET there is the class [[http://msdn.microsoft.com/de-de/library/vstudio/system.eventargs.aspx|System.EventArgs]] and its descendants.
Line 55: Line 78:
  
 On the other hand the parameter object pattern is already applied here. The parameters lpProcessAttributes, lpThreadAttributes, and lpStartupInfo are pointers to structures which hold further arguments. This is the procedural equivalent of a parameter object. On the other hand the parameter object pattern is already applied here. The parameters lpProcessAttributes, lpThreadAttributes, and lpStartupInfo are pointers to structures which hold further arguments. This is the procedural equivalent of a parameter object.
 +
  
 ===== Description Status ===== ===== Description Status =====
 /* Choose one of the following and comment out the rest: */ /* Choose one of the following and comment out the rest: */
-/*[[wiki:Stub]]*/+[[wiki:Stub]]
 /*[[wiki:Incomplete]]*/ /*[[wiki:Incomplete]]*/
 /*[[wiki:Complete]]*/ /*[[wiki:Complete]]*/
 +
  
 ===== Further Reading ===== ===== Further Reading =====
Line 66: Line 91:
   * [[wiki>Parameter Object]]   * [[wiki>Parameter Object]]
   * [[wiki>Argument Object]]   * [[wiki>Argument Object]]
 +
  
 ===== Discussion ===== ===== Discussion =====
  
 Discuss this wiki article and the pattern on the corresponding [[talk:patterns:Parameter Object|talk page]]. Discuss this wiki article and the pattern on the corresponding [[talk:patterns:Parameter Object|talk page]].
 +
patterns/parameter_object.1374588377.txt.gz · Last modified: 2013-07-23 16:06 by christian