? Best Practice - C-like VS OO ?

Adrien-VAdrien-V Member Posts: 11
In your opinion what is the best practice :

- Coding " C-like" with a little # of contracts where ,for e.g, all your custom types are struct :

contract CLIKE
{
struct A {}
struct B {}
mapping(x=>A) MA
mapping(x=>B)MB
some functions
some get-set
}


- Coding in a "OO" way, e.g. where your custom types are contract :

contract OOA
{
some variables;
some functions;
}
contract OOB
{
some variables;
some functions;
}

contract OOLIKE
{
mapping(x => MA)
mapping(x=>MB)

some functions
}

Comments

  • MetalMetal Member Posts: 17
    Solidity has high level language features yet because it runs on a resource-constrained platform, you need to be very aware of the cost and performance impact of using those features. In that respect, it reminds me of writing apps with Java Card for SIM cards.

    Some features are cost neutral, and you'll want to use them liberally (contract inheritance and method modifiers come to mind), but others have a big impact on gas. Creating a new contract at runtime within a contract is not something you want to do lightly. There are use cases for it, but it's quite a bit more overhead that just storing a few fields in your existing contract.
Sign In or Register to comment.