I'm not sure it's really a "polymorphism" question but anyway... So I have an abstract class and 2 other classes that inherit from it.
Some code from the base class have a variable that would be different between classes that extends the base class.
What's the best way to do that? Override a "get" method? Change the architecture a little to call a function from the base classe to the extended class that would pass the value...
Here's an example (it won't compile, just a little example on how I did it) :
public abstract class BaseAbstract class {
... some code ....
// Here "listName" would change depending on the extending class
protected List<Items> getAllItems(String listName) {
Web.getList(listName);
... some code ...
}
protected abstract List<Items> getAllItems();
}
public class NewClass : BaseAbstract {
protected override void getAllItems() {
return getAllItems("ListNameOfNewClass");
}
}
That's how I did it, but it doesn't feel really clear and easy to maintain IMO.
Any idea or comment welcome!