for me, it depends on the context and the surrounding code.
[EDIT: it makes no sense, sorry] if it were in a method like setSomeObjectProperties (), I would prefer option 2, but maybe create a private method "getProperty (String name)" that removes trailing spaces if removed spaces is not an important operation [/ EDIT]
If property validation is an important step of your method, I would call the method "setValidatedProperties ()" and would prefer a variant of your first sentence:
validatedProp1 = doValidation(someObject.getSomeProperty1()); validatedProp2 = doValidation(someObject.getSomeProperty2()); someObject.setSomeProperties(validatedProp1, validatedProp2);
If validation is not something important for this method (for example, it makes no sense to return properties that are not validated), I would put the validation step in "getSomePropertyX ()"
source share