E
Edward A Thompson
I have an abstract class with an abstract method. When I extend the
class, 4 times out of 4I want to pass the method a String, but 1time
out of 4 I want to pass it another class:
So what I did was define someParam as an Object, and end up with the
following:
abstract class A {
....
abstract calc (Object someParam) {};
....
}
public class A1 extends A {
...
public calc (Object a) { String x = a.toString(); };
...
}
public class A4 extends A {
....
public class calc (Object b) { MyClass m = (MyClass)b; };
....
}
Is this good/bad design? Is it standard? Is there a better way to
accomplish this?
Seems to me this allows something other than String or MyClass to be
passed without the compiler's knowledge.
I appreciate any feedback.
class, 4 times out of 4I want to pass the method a String, but 1time
out of 4 I want to pass it another class:
So what I did was define someParam as an Object, and end up with the
following:
abstract class A {
....
abstract calc (Object someParam) {};
....
}
public class A1 extends A {
...
public calc (Object a) { String x = a.toString(); };
...
}
public class A4 extends A {
....
public class calc (Object b) { MyClass m = (MyClass)b; };
....
}
Is this good/bad design? Is it standard? Is there a better way to
accomplish this?
Seems to me this allows something other than String or MyClass to be
passed without the compiler's knowledge.
I appreciate any feedback.