X-Received: by 2002:ad4:4310:: with SMTP id c16mr6121574qvs.47.1548857599761; Wed, 30 Jan 2019 06:13:19 -0800 (PST) X-Received: by 2002:a81:450:: with SMTP id 77mr132752ywe.6.1548857599531; Wed, 30 Jan 2019 06:13:19 -0800 (PST) Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!v55no1450127qtk.0!news-out.google.com!m21ni682qta.0!nntp.google.com!v55no1450120qtk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Wed, 30 Jan 2019 06:13:19 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=192.176.1.80; posting-account=1c_fOgoAAADuOXlL0A4-T9PUmVHtMSYd NNTP-Posting-Host: 192.176.1.80 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: How to make my library independent using DI From: mike Injection-Date: Wed, 30 Jan 2019 14:13:19 +0000 Content-Type: text/plain; charset="UTF-8" Lines: 27 Xref: csiph.com comp.lang.java.programmer:38722 Hi Andreas, Thanks for your comments. I really appreciate them. > Not sure what you mean by inject, but according to your code snippet, > there is no "hard dependency" to AHelper in your lib. I will definitely check for null. I think I need to do a litte bit more explanation. I need to create an instance of AHelper, in the application using the library,and inject it into my lib. Otherwise I will not be able to access the data from version() and productNumber(). I mean shall I call: MyDataClassImpl( new AHelper()) from the application? And at what point in time should this be done. And if the MyDataClassImpl needs more external data, let's say from BHelper() also, do add the following in my app: MyDataClassImpl(new AHelper(),new BHelper()) ? Thanks for helping out!! //mikael