Oh, abbreviations in code, the bane of every developer.
Consensus seems to be against them, because readability might be affected. But the examples given are often extreme: like "repr" for "represent". I call that extreme, because it is shortening a word not in need of shortening, into something that has a very ambiguous meaning.
Please consider my example as a possible example of when abbreviations may be justified. I've got a project that uses a number of projections, which are basically views on a Mongo-database. To name a projection descriptively, you have to describe the perspective, which takes a few words. And each projection has a number of classes to make it work, each of which have names of their own, suffixed to the projection name.
So, because I have a projection named StatemachineDefinitionRelevantEvents (take my word for it that this is the shortest way to describe the projection), I also have classes named StatemachineDefinitionRelevantEventsAggregrateProjection, StatemachineDefinitionRelevantEventsReadModel, StatemachineDefinitionRelevantEventsRepository. Those are around 50 characters long.
Because vars are also disallowed (company policy), you get code like this:
StatemachineDefinitionRelevantEventsAggregrateProjection statemachineDefinitionRelevantEventsAggregrateProjection = new StatemachineDefinitionRelevantEventsAggregrateProjection(<bunch of parameters with similarly lengthy names>);
Repeated over and over if I need to create several of these classes in a row.
I decided to just replace every instance of StatemachineDefinitionRelevantEvents with SDRE. I'm also clearly noting in my ubiquitous language and documentation that SDRE stands for StatemachineDefinitionRelevantEvents, with an explanation of the projection's definition and purpose. Lo and behold, my initialisations suddenly fit on a single line! And the suffix always remains unabbreviated, so even if you don't know what SDRE means, the function of a SDRERepository, SDREReadModel and SDREAggregrateProjection should be interpretable from the name alone.
Is this an example of justified and 'good' use of abbreviations, or is it still wrong? I want to get a second opinion before I propose it to the team.
SdreRepository. sdreRepository = new ...;
. I find it easier to read than a bunch of capital letters mashed together. As to whether or not this is good - I think it comes down to whether you and your team can agree on the convention and also the definition of "SDRE."