Merge pull request #6790 from ethereum/docModular

[Docs] Better explain the modular approach.
This commit is contained in:
chriseth 2019-05-23 14:36:22 +02:00 committed by GitHub
commit 2491ce45a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,10 +4,18 @@
Modular Contracts
*****************
A modular approach to building your contracts helps you prevent overflow risks
and unexpected tokens. In the example below, the contract uses the ``move`` method
A modular approach to building your contracts helps you reduce the complexity
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
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.
::