How do you name repository and service interfaces and their implementing classes?
For example I have a model with the name Question. What would you 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 already had done 🙂
I think that there are roughly two approaches to naming in DDD:
1) Stereotype based. This is where you include class stereotype in its name. For example:
2) Domain based. In this approach you use only domain language and omit any stereotypes in the class names. For example:
Implementation classes would be named like
SqlQuestionsorInMemoryQuestions.I tried both but I now prefer 2nd option as it seems to be more aligned with DDD mindset. It seems more readable and have a better signal-to-noise ratio. Following is a quote from a great article on repositories by Phil Calçado:
The whole article is well worth reading and bookmarking.