mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6790 from ethereum/docModular
[Docs] Better explain the modular approach.
This commit is contained in:
commit
2491ce45a1
@ -4,10 +4,18 @@
|
|||||||
Modular Contracts
|
Modular Contracts
|
||||||
*****************
|
*****************
|
||||||
|
|
||||||
A modular approach to building your contracts helps you prevent overflow risks
|
A modular approach to building your contracts helps you reduce the complexity
|
||||||
and unexpected tokens. In the example below, the contract uses the ``move`` method
|
and improve the readability which will help to identify bugs and vulnerabilities
|
||||||
|
during development and code review.
|
||||||
|
If you specify and control the behaviour or each module in isolation, the
|
||||||
|
interactions you have to consider are only those between the module specifications
|
||||||
|
and not every other moving part of the contract.
|
||||||
|
In the example below, the contract uses the ``move`` method
|
||||||
of the ``Balances`` :ref:`library <libraries>` to check that balances sent between
|
of the ``Balances`` :ref:`library <libraries>` to check that balances sent between
|
||||||
addresses match what you expect.
|
addresses match what you expect. In this way, the ``Balances`` library
|
||||||
|
provides an isolated component that properly tracks balances of accounts.
|
||||||
|
It is easy to verify that the ``Balances`` library never produces negative balances or overflows
|
||||||
|
and the sum of all balances is an invariant across the lifetime of the contract.
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user