1

What is the big difference between:

contract Crowdsale {
    MintableToken public token;
    uint256 public someInt;
    [...]

    function Crowdsale (uint256 _constructorArgument){
      someInt = _constructorArgument;
      token   = createTokenContract();
    }

    function createTokenContract() internal returns (MintableToken) 
    {
      return new MintableToken();
    }

and

contract Crowdsale {
    MintableToken public token = new MintableToken();
    uint256 public someInt     = theValueIWouldPassAsConstrArgument;
    [...]

    function Crowdsale (){

    }

The second version is much cleaner imho. I have less code. No need for constructor Arguments...

What is the difference? I would prefer the second version. But maybe I am wrong.

1 Answer 1

3

The second version will only work with hardcoded values.

How would you instantiate a new object with different paramters, dynamically?

You can't do this:

Crowdsale c = new Crowdsale(10);
1
  • Ok, makes sense. But there is no difference? Actually most examples do not need dynamic values. If this is the only reason I would stick to my version as long as I do not need dynamic creation...
    – kn1g
    Commented Dec 15, 2017 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.