Question

I feel this is a basic question wiht some trick.
I want to extend the functionality of ActionBar, upon looking up the ActionBar code it turns out ActionBar is an abstract class and the real instantiated class is ActionBarImpl.
This pattern of having an abstract and a Impl for implementation is widely used in android source code.
The developers site does not dwell in details, but always describes the abstract class as if it was the implemented class.
I see that from the java language strict point of view I should extend ActionBarImpl, otherwise I will not be able to call super methods, but I have never seen an example out there extending the <class>Impl classes.
Help.

Was it helpful?

Solution

The only difference between the abstract and implementation in this case is likely to be the abstract method(s). If the default behavior provided by the implementation class is acceptable, I'd say extend that and override the other methods you need.

If the abstract method behavior you want means you can't use the implementation at all, then extend the abstract class.

OTHER TIPS

Yes, you should extend the Impl class for extensions, because if you extend the abstract class, you will have to provide the implementation of abstract methods and if it is not your intention to "change" the existing behavior but only to "extend" or add new behavior then you better extend Impl class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top