Here's the deal: I have two objects of different classes: DataSizeAction and DataColorAction . Classes have a common ancestor EncoderAction not far from the chain.
Both of these objects expose a method called setScale(int scale) , which sets the type of scale for the encoding to be performed. The method does the same in both cases.
However, this method is absent from any common ancestor (by the way, this OO is the library that I use, and the design does not fit my discretion).
I would like to write a method that takes a DataSizeAction or DataColorAction and calls setScale on this object.
My question is: before I go into individual cases with instanceof , is there a more elegant way to handle this?
Thanks!
source share