I have a hierarchy of classes:
class Page {
}
class ChildPage1 extends Page {
private static final String URL;
}
class ChildPage2 extends Page {
private final String url;
}
Some pages have static urls but other don’t. I need some methods like load() in parent class Page that will use url of it’s descendant. I thought about implementing it in these ways:
- using reflection api
- naming static final URLs in lowercase (in conroversary to naming conventions).
Is it worth to not follow naming conventions in this case?
You can solve your problem by adding an abstract method
getUrl()toPagethat has to be implemented inChildPage1andChildPage2.