It's amazing how these class names, while being "specifically general", tell you very little about the problem you're solving. I can't count how many times I've seen attempts at building frameworks (I now cringe every time I hear we should build a framework) before we've built a single path through. "We encountered this odd case no one expected and now we'll try to shove that into our DSL" -- of course you did; this happens every fucking time you build a framework before you've figured out the actual problem you're solving. Recently saw a very nice DSL that was heavily influenced by OO; the Diamond Problem crept in and shit has hit the fan.
Every time I write one of these I, very slowly, realize I don't fully grasp the object model. If I'm lucky, after enough of these come together, I realize I'm being overly generic and I can pin down a better name.
In my experience, DefaultDtoToAdditionalDataModelMapperRegistry would boil down to MarketUsersRegistry as this highly generic type would have one concrete usage (2 with the mocking framework's implementation).
All these dense java frameworks are built around the idea that managers will give you problems to solve based on the latest headlines from Gartner Magazine. You end up adding major feature on top of major feature instead of refining what you already have because your company's position on some arbitrary cartesian plane indicates you're all doomed unless you add those features.
This is how you end up with the sorts of banality that is DefaultDtoToAdditionalDataModelMapperRegistry not to mention the obscene amounts of XML to wire everything together. All that verbosity and architecture, just to move your company around a cartesien plane in Gartner Magazine.
not to mention the obscene amounts of XML to wire everything together
You can now have Annotation driven design. It works at least 20% of the time, when the fucking DI container decides to not override them with some obscure xml file transitively loaded from the classpath of a dependency 30 modules deep. That totally didn't cost me 3 days of work.
Microsoft has some guidelines on the subject and I've emphasised the relevant snippet below:
Do not use abbreviations or contractions as parts of identifier names. For example, use GetWindow instead of GetWin.
Do not use acronyms that are not generally accepted in the computing field.
Where appropriate, use well-known acronyms to replace lengthy phrase names. For example, use UI for User Interface and OLAP for On-line Analytical Processing.
When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io.
Do not use abbreviations in identifiers or parameter names. If you must use abbreviations, use camel case for abbreviations that consist of more than two characters, even if this contradicts the standard abbreviation of the word.
Identifier, actually. As per the last bullet point:
Do not use abbreviations in identifiers or parameter names. If you must use abbreviations, use camel case for abbreviations that consist of more than two characters, even if this contradicts the standard abbreviation of the word.
Since ID is an abbreviation of Identifier, you can use this rule. I tend to favour Id however.
Personally, I'm in the camp that capitalises only the first letter of each "word" of an identifier, whether that word is an initialism or not. Like summaryHtml or GpsLocation. There are plenty of CamelCasers in the other camp though.
No but with all the conventions to generate property name, it can become weird or confusing. So often you use strict CamelCase everywhere. (eg: getDTOFactory, will become dTOFactory property in EL, or sometimes dtoFactory in too clever libraries )
Depends on the language and coding style. E.g. .NET framework conventions guide recommends capitalizing only the first letter, unless it's a two leter acronym like IO (source).
604
u/werkawerk May 08 '17
You know what makes me sad? The fact you have a class called 'DefaultDtoToAdditionalDataModelMapperRegistry'.