Timeline for Is "Introduce Parameter Object" actually a good pattern?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 30, 2016 at 13:26 | comment | added | Doc Brown | @user2180613: one important point in this answer is IMHO "your example is too abstract too tell". If a class (parameter object or whatever) is conceptually correct depends on if it groups things together which belong together and can be given a descriptive name. If you can group one parameter object together with one additional parameter under a good, descriptive name, then it is probably conceptually correct. If the grouping is very artificial, then it is not. | |
Aug 30, 2016 at 13:06 | comment | added | user2180613 | @DocBrown I understand the advantage of creating small objects on the fly for some distinct functionality. The question is if this is a conceptually correct, because I see issues when I apply this solution consistently. I could imagine that additional arguments should cause the creation of another ParameterObject. | |
Aug 30, 2016 at 12:56 | comment | added | JacquesB |
@user2180613: It depends what A and B is. Whether a pattern is appropriate always depends on a particular situation and what your code is trying to achieve. It like asking if it is appropriate to create an adapter for a class called X or a decorator for class called Y - it is impossible to answer. Try to come up with a realistic example.
|
|
Aug 30, 2016 at 12:54 | comment | added | Doc Brown | @user2180613: If an additional method has an additional argument, then introducing the PO reduces the number of arguments from 4 to 2 (the parameter object + the additional parameter). And 2 parameters instead of 4 is still an advantage. | |
Aug 30, 2016 at 12:40 | comment | added | user2180613 | It is always possible to group parameters in a class, given that one can come up with a name for that class. So if it is correct practice to group them in a ParameterObject or ValueObject (I'm unsure what the best name is), then where is the limit? All I want in A is the result of some calculation and it turns out that it is not very convenient to pass all that calculation's arguments around all the time. So I could create a ParameterObject. But what if B has an additional argument? Does a new ParameterObject emerge? | |
Aug 30, 2016 at 11:43 | history | edited | JacquesB | CC BY-SA 3.0 |
added 494 characters in body
|
Aug 30, 2016 at 11:27 | history | answered | JacquesB | CC BY-SA 3.0 |