It does indeed seem smelly, and without seeing more context it's impossible to say for sure. There could be two reasons for doing this, although there are alternatives for both.
First, it's a concise way of implementing partial conversion, or leaving the result with default values if conversion fails. That is, you might have this:
public void ConvertFoo(Foo from, Foo to) {
if (can't convert) {
return;
}
...
}
Foo a;
Foo b = DefaultFoo();
ConvertFoo(a, b);
// If conversion fails, b is unchanged
Of course, usually this is handled using exceptions. However, even if exceptions need to be avoided for whatever reason, there's a better way to do this - the TryParse pattern being one option.
Another reason is that it could be for purely consistency reasons, for example it's part of a public API where this method is used for all conversion functions for whatever reason (such as other conversion functions having multiple outputs).
Java's not great at dealing with multiple outputs - it can't have output-only parameters like some languages, or have multiple return values like others - but even still, you could use return objects.
The consistency reason is rather lame but sadly it may be the most common.
- Perhaps the style cops at your workplace (or your codebase) come from a non-Java background and have been reluctant to change.
- Your code may have been a port from a language where this style is more idiomatic.
- Your organisation may need to maintain API consistency across different languages, and this was the lowest-common-denominator style (it's daft but it happens even for Google).
- Or perhaps the style made more sense in the distant past and morphed into its current form (for example, it could have been the TryParse pattern but some well-intentioned predecessor removed the return value after discovering that nobody checked it at all).
oo
is an object that is passed to the method, not a pointer that is set to a new object. Is that the case here? If this is Java it probably is, if its C++ it might not be