• Create Account

# Mikea15

Member Since 05 Dec 2008
Offline Last Active Jan 04 2016 08:57 AM

### #5145178Constructor Chaining Order to Parameters or Parameterless.

Posted by on 07 April 2014 - 03:39 PM

So I guess, I would have to re-think on how much control those classes provide. Thank you

### #5144952Constructor Chaining Order to Parameters or Parameterless.

Posted by on 07 April 2014 - 02:16 AM

Okay, so there is no "best way" to do it. That's what I wanted to know.

Thanks for the feedback.

Edit:

To get a better view. Here's the main difference with another class.

```public X( )
{
Left = 0;
Right = 0;
BreakLeft = false;
BreakRight = false;
BreakTime = 0;
}

public X(int speed)
: this( )
{
Left = speed;
Right = speed;
}

public X(int left, int right)
: this( )
{
Left = left;
Right = right;
}

public X(int left, int right, int time, bool breakWheel)
{
Left = left;
Right = right;

BreakLeft = breakWheel;
BreakRight = breakWheel;

BreakTime = time;
}

public X(int left, int right, int time, bool breakLeft, bool breakRight)
{
Left = left;
Right = right;

BreakLeft = breakLeft;
BreakRight = breakRight;

BreakTime = time;
}
```

And Method 2:

```public X( )
: this( 0 )
{

}

public X(int speed)
: this( speed, speed )
{

}

public X(int left, int right)
: this( left, right, 0, false )
{

}

public X(int left, int right, int time, bool breakWheel)
: this( left, right, time, breakWheel, breakWheel )
{

}

public X(int left, int right, int time, bool breakLeft, bool breakRight)
{
Left = left;
Right = right;

BreakLeft = breakLeft;
BreakRight = breakRight;

BreakTime = time;
}
```

For this particular case. This is the better approach. It has less code, Its easier to maintain and is cleaner.

### #4983754Stuck in a programmers rut.

Posted by on 25 September 2012 - 03:47 PM

One thing you can do is leave an error, and a comment, so the next time you get to work on the project, you compile, know where the error is, read the comment, and everything will be clear in your head.

PARTNERS