mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Improved the "Naming" section
Improved the "Naming" section. Added naming examples. Improved consistency.
This commit is contained in:
parent
cacc0e4b46
commit
f39cf7be41
@ -696,49 +696,51 @@ indistinguishable from the numerals one and zero.
|
||||
Contract and Library Names
|
||||
==========================
|
||||
|
||||
Contracts and libraries should be named using the CapWords style.
|
||||
Contracts and libraries should be named using the CapWords style. Examples: ``SimpleToken``, ``SmartBank``, ``CertificateHashRepository``, ``Player``.
|
||||
|
||||
|
||||
Events
|
||||
======
|
||||
Event Names
|
||||
===========
|
||||
|
||||
Events should be named using the CapWords style.
|
||||
Events should be named using the CapWords style. Examples: ``Deposit``, ``Transfer``, ``Approval``, ``BeforeTransfer``, ``AfterTransfer``.
|
||||
|
||||
|
||||
Function Names
|
||||
==============
|
||||
|
||||
Functions should use mixedCase.
|
||||
Functions should use mixedCase. Examples: ``getBalance``, ``transfer``, ``verifyOwner``, ``addMember``, ``changeOwner``.
|
||||
|
||||
|
||||
Function Arguments
|
||||
==================
|
||||
Function Arguments Names
|
||||
========================
|
||||
|
||||
Function arguments should use mixedCase. Examples: ``initialSupply``, ``account``, ``recipientAddress``, ``senderAddress``, ``newOwner``.
|
||||
|
||||
When writing library functions that operate on a custom struct, the struct
|
||||
should be the first argument and should always be named ``self``.
|
||||
|
||||
|
||||
Local and State Variables
|
||||
=========================
|
||||
Local and State Variables Names
|
||||
===============================
|
||||
|
||||
Use mixedCase.
|
||||
Use mixedCase. Examples: ``totalSupply``, ``remainingSupply``, ``balancesOf``, ``creatorAddress``, ``isPreSale``, ``tokenExchangeRate``.
|
||||
|
||||
|
||||
Constants
|
||||
=========
|
||||
|
||||
Constants should be named with all capital letters with underscores separating
|
||||
words. (for example:``MAX_BLOCKS``)
|
||||
words. Examples: ``MAX_BLOCKS``, `TOKEN_NAME`, ``TOKEN_TICKER``, ``CONTRACT_VERSION``.
|
||||
|
||||
|
||||
Modifiers
|
||||
=========
|
||||
Modifier Names
|
||||
==============
|
||||
|
||||
Use mixedCase.
|
||||
Use mixedCase. Examples: ``onlyBy``, ``onlyAfter``, ``onlyDuringThePreSale``.
|
||||
|
||||
|
||||
Avoiding Collisions
|
||||
===================
|
||||
Avoiding Naming Collisions
|
||||
==========================
|
||||
|
||||
* ``single_trailing_underscore_``
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user