Solved

Dependency injection names?

Posted on 2014-12-02
1
51 Views
Last Modified: 2015-02-23
I want to create my own dependency injection in my Java code and wonder what the names would be for different parts.

Lets say I have an Interface X.
It is being implemented by my class Y w.   ich is ijected with my class Z at creation time. What would sensible names be then?
FooBarInterface
FooBarService
FooBarHandler

Any better ideas?
0
Comment
Question by:mdoland
1 Comment
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 40477498
You haven't given enough information to begin to advise on good names for YOUR situation. That is the issue here, it is totally dependant on YOUR particular application/design.

But maybe giving you an example of a more real-world case (rather than X, Y, Z and FooBar...). So say you have a need to get products from an inventory database. At a really high level you might have a "ProductService" class and it needs to be injected with an instance of the "ProductDataSource" interface. Therefore, you might implement an "OracleProductDataSource" class that implements the ProductDataSource interface by accessing an Oracle database to actually fetch the required information. In production, you can inject an instance of that class into your ProductService. And then in testing you could create a "TestProductDataSource" class that just provides some test data to assist in testing your ProductService.

This is still somewhat theoretical and depending on the application you may even break this up into additional levels, but it is just an example for possible naming conventions and the one that I try and use. The main theme from the above, is that I usually DON'T have Interface in the name of my interfaces, and classes that implement my interfaces "prepend" some descriptive word(s) to the front of the interface name. Just one more quick example to give you the idea... you might have an EventProducer interface and implementations of it called KeyboardEventProducer and MouseEventProducer, etc.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 84
fibonacci ten numbers 4 38
web application structure 18 77
How do I remove an object from a 3 26
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question