Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions contributors-guide/standards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ These style guides are chosen because they can be easily enforced and checked us

The goal of these guides is to ensure an easy developer workflow and reduce code commits that contain changes for the sake of style over content. By reducing the noise in diffs we make the job of reviewers easier.


### Naming Conventions

To avoid confusion and guarantee cross-language interoperation, follow these rules regarding naming conventions:
- Do not use abbreviations or contractions as parts of identifier names. For example, use `SettlementWindow` instead of `SetWin`.
- 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`.
- Use Pascal case or camel case for names more than two characters long depending on context (e.g. class names vs variable names). For example, use `SettlementWindow` (Class) or `settlementWindow` (Variable). However, you should capitalize abbreviations that consist of only two characters, such as `ID` instead of `Id`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about preferring ID over Id, but maybe that's personal preference. We seem to favour Id over ID in our code

But then again, maybe that's because Id is short for Identifier and not IDentifier....

Copy link
Member Author

@mdebarros mdebarros Dec 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, perhaps I should expand that to include: "where abbreviations are isolated and not part of a composite name".

i.e. The following would be valid:

  • /transfer/{{TransferId}
  • /transfer/{{ID}}

Example of this --> https://github.com/mojaloop/central-services-shared/blob/master/src/enums/endpoints.js#L110 <-- although our Enums are not adhering to the above-suggested convention :D

Based on the above example, we may need to add an exception for ENUMs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, 100% agree. Thanks for clarifying.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lewisdaly please have a look at my updates.

- Avoid 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.

Ref: [Microsoft - Design Guidelines for Class Library Developers](https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-1.1/141e06ef(v=vs.71)?redirectedfrom=MSDN)

### Code Style

#### Javascript
Expand Down