Naming rules #119
emil14
started this conversation in
Conventions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Naming
Names are short rather than long. Package context (which should be small) and type information should help.
These rules must not caused compile error and should be enforced by linter instead.
Packages
Short (1-3 words)
lower_snake_case
. Examples:math
,postgres
,limit_service
Components
Short (1-3 words)
UpperCamelCase
nouns usually with "er" ending. Examples:Reader
,NetWriter
,CachedStrConvertor
Nodes
Same as components but start in
lowerCamelCase
. E.g. instance ofReader
should bereader
. If there's several Reader instances then some context should be added. E.g.fileReader
,netReader
, etc. Same goes for interfaces exceptI
prefix must be removed. E.g.reader IReader
.Many instances of the same component could mean that the network is too big and must be somehow separated.
Types
UpperCamelCase
. Examples:User
,Phone
,LocalTime
Interfaces
Like components but with
I
prefix. Examples:IReader
,IWriter
,IStringConvertor
Constants
UPPER_SNAKE_CASE
. Examples:PI
,KAZAKHSTAN_PHONE_CODE
Ports
Short (1-5 letters)
lowerCebabCase
for port names. Example:It's common to aggressively abbreviate type names when naming ports. Examples:
User
->u
,LocalTime
->lt
Common names
v
- value of type that doesn't matterb
- byte values
- string valueerr
- error valueok
- bool value that represent success/failure e.g. finding an element in a mapsig
- signal value (of any type)ctx
- contextPlural
Plural is represented by doubling single-letter name. Examples:
vv
,bb
,ss
. Plural must be used instead of singular every time port operates on collection (array/vector/map)Record fields
lowerCamelCase
like in JSON. Example:Shadowing
Shadowing is forbidden by compiled for
build
mode, available for interpreter. E.g. one cannot createInt
component if there is builtinInt
data-type. Same way there cannot beBeta Was this translation helpful? Give feedback.
All reactions