Public abstract class Profile <T extends ProfileOpt> {
..
}
Class A extends Profile<class C> {
..
}
Class B extends Profile<class D> {
..
}
Class D extends class C {
..
}
I have a method which has common code both in
class A
update(String xyz, C c) {
}
Class B
Update (String abc, D d) {
}
I understand writing update method in both Class A and B is a bad idea, I need to reuse the code.
One way I can think of is to create a separate Update class with only this method and then instantiate Update and A and B and make a method call from both classes with respective arguments.
Is there any better way for this or this is good from OOPS perspective?
Aucun commentaire:
Enregistrer un commentaire