Update 'Style Guide'
parent
eb3058c005
commit
9a3b54ea00
@ -159,3 +159,26 @@ const (
|
|||||||
All enum values the ARF compiler are prefixed with the name of the enum they belong to, as shown above.
|
All enum values the ARF compiler are prefixed with the name of the enum they belong to, as shown above.
|
||||||
|
|
||||||
The `iota` keyword just initializes everything in the block with incrementing values.
|
The `iota` keyword just initializes everything in the block with incrementing values.
|
||||||
|
|
||||||
|
# Naming Things
|
||||||
|
|
||||||
|
Choose descriptive, even lengthy names for things, but don't go absolutely crazy. Use full words, and separate them using camel case. Never, ever use single letter variables (yes, including `i`). For example, say you wanted to name a struct that stored a database of cached parsing results:
|
||||||
|
|
||||||
|
These are overly terse and do not convey meaning well. Imagine trying to decipher the meaning of these among a sea of symbols and other names.
|
||||||
|
```
|
||||||
|
Cache
|
||||||
|
PCache
|
||||||
|
PCacheDB
|
||||||
|
```
|
||||||
|
|
||||||
|
This is excessive. Imagine writing a method for this!
|
||||||
|
```
|
||||||
|
DatabaseOfCachedParsingOperationResults
|
||||||
|
```
|
||||||
|
|
||||||
|
This is perfect.
|
||||||
|
```
|
||||||
|
ParsingResultCache
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: it can be easier to have somewhat longer names for variables, functions, and members, and somewhat shorter names for types.
|
Reference in New Issue
Block a user