Question

We are building a software application for a client with a particular naming convention for REST services.

For example if you use a POJO for your request or response in a REST service something like that:

public class Document {
    private String codeDocument;
    private String codeParentDocument;
    private Double amountPayed;
    private String nameOwner;
    private String descriptionDocument;
}

Your REST contract should be so:

{
  "codDocument": "123",
  "codParentDocument": "123",
  "amtPayed": 25.5,
  "desDocument": "owner"
}

[EDIT]

As you can see, some attributes names are using accronyms ("cod", "amt", "des"). There are many others that are used in this project.

I would like to know if the use of this "acronyms" can be considered as a bad practice or in contrast, don't break any good practice?

Thanks in advance for your opinions!

Was it helpful?

Solution

Your naming convention looks like a variant of Hungarian notation where the acronyms correspond to semantic categories and replace the type.

As with all naming conventions: there is no good nor bad practice. The most important point is to use the convention consistently.

To answer this question objectively, one could only look at pros and cons:

  • The pros in your case seem to be consistency with the existing code, including applications consuming your project's interface. Another pro is the principle of least surprise, if the company has other projects using the same convention, especially if customers/partners are already used to it.

  • The cons are the reduced readability, the ambiguity of acronyms used elsewhere than at beginning (e.g. is it currencyAmt or currencyAmount?), the error-prone mixing of acronyms with plain names (e.g. was it codParentDoc or codParentDocument?), the different convention for internal and external conventions.

If pros are aknowledged, thes shall outweight the cons.

Licensed under: CC-BY-SA with attribution
scroll top