Solved

Dependency injection names?

Posted on 2014-12-02
1
56 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
[X]
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
1 Comment
 
LVL 36

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

688 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