This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
The second one, two stage as your going to reuse the returned value multiple times in your example code .. its more efficient, error messages will be easier to read for a beginner and it'll be easier to see what's going on in a debugger. The alternative wasn't the end of the world though.
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
From a performance point of view, it is wise to cache results of methods if you need them more than once. Even if a method just returns a value now, it can be changed to include complex calculations or even file I/O or database interactions at some time. By caching the results, you will ensure that the method is called only once and there will be no more duplicate execution of the same (possibly complex or time consuming) code.
I disagree with the previous posts. If you're making multiple calls to setColor, I think that the first code snippet makes it a lot more clear where the color is coming from, and doesn't require that you introduce a temporary variable. As for optimization, Color objects are immutable, so the composer.getReminderColor() method probably just returns a reference anyway. Introducing the temporary variable probably isn't saving you any time at all.
When in doubt I always remember the following:
1. Code for clarity. 2. Run with a profiler. 3. Optimize the bottlenecks if necessary.