So I made a mistake.
When originally writing a signature for an API, I created something like this:
public JellyBeanResult getJellyBeanReport();
Now, it turns out that I would like to re-use the more specific JellyBeanResult object because of its functionality, but it would be confusing to have other functions return a type named for a different process. There are a couple of ways to fix this that I can think of. I could re-name the return type to something more generic:
public GenericResult getJellyBeanReport();
public GenericResult getChocolateBarReport();
but that would break any code that is using the API. I could create a new, more accuratly named class that extends SpecificResult that more closely fits the new function:
public class ChocolateBarResult extends JellyBeanResult{};
public JellyBeanResult getJellyBeanReport();
public ChocolateBarResult getChocolateBarReport();
But this is really, really ugly and the problem still sticks around if I want to to use the return type again down the road. How can I clean up these signatures to make them less confusing without breaking any code that is using them?
Move the core functionality from JellyBeanResult to GenericResult and have JellyBeanResult extend GenericResult:
or if you want to be completely consistent: