Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Dependency injection names?

Posted on 2014-12-02
1
54 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 64
servlet example issue 6 46
Running JavaFX on JDeveloper 12C 1 52
Crystal Reports Licensing Questions 4 34
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

789 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