Java – how do I name repositories and service interfaces?
How do I name the repository and service interfaces and their implementation classes?
For example, I have a model called question You will name the repository (interface and Implementation) and the service (interface / implementation)
After reading these posts: Java interfaces / implementation naming convention and interface naming in Java, I reconsidered what I had done:)
Solution
I think there are roughly two methods of naming in DDD:
1) Based on stereotypes This is where you include the class stereotype in its name For example:
QuestionsRepository,TaxCalculatingService etc
2) Domain based In this approach, you only use the domain language and omit any stereotypes in the class name For example:
Questions (or AllQuestions),TaxCalculator etc.
The implementation class will be named sqlquestions or inmemoryquestions
I've tried two, but now I prefer the second option because it seems to be more in line with the DDD thinking mode It seems more readable and has better signal - to - noise ratio The following is philcal ç ADO's quotation for the inventory of great article:
class OrderRepository { List<Order> getOrdersFor(Account a){...} }
class AllOrders { List<Order> belongingTo(Account a){...} }
The whole article is well worth reading and bookmarking