Take the 2-minute tour ×

I was designing a library in JAVA which provides different service objects and all these objects could have different functionality (aka functions).

I was thinking of having a parent abstract class which is responsible for providing these different service classes via get methods but the consumer of library would need to write lot of boiler plate code always like


Is there a design pattern which I can use in this scenario ?

share|improve this question

2 Answers 2

It depends on how you want to load your library, still, Facade pattern can do the work here.

share|improve this answer

I would recommend using Dependency Injection where your library will be replaced by the DI container that will house the instances of implementation classes of these services and your client simply declare the dependency on the service and the DI framework will take care of injecting them at runtime appropriately.

share|improve this answer

Your Answer


