I have a class like this:
class X {
X (databaseconn, httpclient) {
this.httpclient = httpclient
this.databaseconn = databaseconn
}
public func1(a, b) {
// ...
}
public func2(x, y, z) {
// ...
}
// ...
public funcN(p, q, r) {
// ...
}
}
There are very few methods in the class that operate on the injected httpclient
(either directly or through some other method). Creating and injecting it, therefore, seems unnecessary and wasteful to me.
What pattern should be followed when there is a rarely used dependency such as the httpclient
in this case?