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.

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);
  • 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 Dec 15 '17 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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