I read that data coupling can be reduced by "not passing unnecessary arguments"
Say there is a makeCake
method which requires many instance variables in the Ingredients
class as parameters:
makeCake(ingredients.flour, ingredients.egg, ingredients.sugar, ingredients.cheese, ingredients.cream)
And instead of this, just pass the whole Ingredients Object
makeCake(ingredients)
and access the variables within the makeCake
method..
Is this counted as reducing coupling between the class which calls the makeCake method and the Ingredients class? Before you were passing 5 arguments and now you're only passing one?
(Note that this question was made with the Java language - and the OO side of Scala - in mind)
(sorry if this question is making you crave cake, it was the first thing that popped into my head) :)
I think not so much.
I think a change in the format is not the idea.
Rather, if you passed an "ingredients id" and let the target look up what it needed....that would be less coupled.
see http://depfind.sourceforge.net/Manual.html#Dependencies: