Once a smart contract has been deployed on the Ethereum network, it is immutable and public to everyone. Many of the smart contract functions are account payment related; therefore, security and testing become absolutely essential for a contract before being deployed on the main network. Following are security practices that will help you better design and write flawless Ethereum smart contracts.
Smart contract security
Keep contract simple and modular
Try to keep your smart contract small, simple, and modularized. Complicated code is difficult to read, understand, and debug, it is also error-prone.
Use well-written library tools where possible.
Limit the amount of local variables.
Move unrelated functionality to other contracts...