27

Coming from other C++ projects like Unreal Engine I was surprised to see coding standards in the EOS codebase is all lowercase, not only for variables but even for class names.

Is there any resource to read about which standards to follow while contributing to the source? or even more important "while writing new smart contracts?"

Outlined in this standard would be things like:

  • Naming of variables, functions and types,
  • Spacing (2 spaces, vs 4, vs tabs),
  • Spaces around parentheses,
  • Curly braces on same line or dedicated lines,
  • Naming of iterator variables or private variables, e.g. with leading underscore,
  • ...

I guess optimally it would be nice if the community agree for certain conventions to make it easy, to switch from project to project in the EOS space.

For example the following C++ coding styles have been documented:

What are the best practices, and what is the current coding style?

  • There is a good question. There is no good answer! – smarteasy Jun 19 '18 at 10:47
  • I am frustrated because I can not get a good answer. I can not access block.one wiki. – smarteasy Jun 19 '18 at 10:49
7

Yes, it can be found on the Developers Portal here.


Deprecated

EOSIO GitHub wiki

  • There are also naming conventions here – confused00 Jul 18 '18 at 14:04
5

It seems to be shared only internally. After being committed, it seems to be reflected in the document below. https://blockone.atlassian.net/wiki/spaces/ID/pages/10518529/Coding+Standards

Why do they open this that looks so useless? https://github.com/EOSIO/eos/wiki/Coding-Standards

1

The coding standards can be found on The EOS Developers Portal. However they are very basic.

Some things to consider:

  1. When creating function names or table names, there is a 12 character limit, and only lower case letters and the numbers 1-5 are allowed. No underscores or anything else.
  2. When creating a table, the scope of the table should be either the same as the contract name, or it should be meaningfully linked to something else. For example: cleos get table eosio eosio global for an example of a scope matching the contract name, and cleos get table eosio.token EOS stats for a scope that differs from the contract name. See this question for more details on this.

If anyone has any more suggestions for best coding practices, please add them to my list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.