I have the following two inheritance chains:
BaseQueryBuilder BaseApplication
| |
| |
AppQueryBuilder Application
BaseQueryBuilder
is an abstract class, which AppQueryBuilder
extends by adding additional query builder methods that are specific to the application. BaseApplication
is interface that Application
implements. I'm using composition to merge the to, so the constructor for Application
looks something like the following:
class Application(AppQueryBuilder queryBuilder) {
_queryBuilder = queryBuilder;
}
Note that other functions in Application
depend on the existence of methods in AppQueryBuilder
that are not defined in BaseQueryBuilder
, but rather added in the definition of AppQueryBuilder
.
Question: Is this poor style? I'm a bit uneasy about the fact that Application
's constructor requires a concrete implementation, named AppQueryBuilder
, rather than accepting its parent interface (though this is not possible, as I've described above). Is there a cleaner, obvious alternative design pattern that I should be using?