From Effective Java Item 18 where it suggests we can combine interfaces and abstract classes by providing an abstract skeletal implementation class. I am wondering when should we use skeletal implementation for simulated multiple inheritance ? and what are the advantages and disadvantages ? Can someone give an example ?
From Effective Java Item 18 where it suggests we can combine interfaces and abstract
Share
The point of a “Skeletal class” as you put it is mainly to enforce certain ground rules that will govern the use of your design. By themselves, interfaces and abstract classes cannot do the job. Consider the interface for example
So this means that using an interface alone to specify the rules of a design will still permit abuse of the operations defined in your interface, you’ll not be able to specify important class level variables or take full advantage of inheritance.
Now take the abstract class
Combining both gives you the best of both worlds in that
Serializabletype interfaces for marking that will be extended by other interfacesConsider this use case
then you have a marker interface that you need simply for identification purposes, so you can use maybe instanceOf operator on.