Is it better to set a class's properties or to pass arguments to the class
initially in the constructor?
The two concepts are not related. You pass arguments to the constructor when
you want to use that data to initialize your object. You set properties when
you want to change the current value of the property. One is not better than
the other.
Another thing constructors are good for is letting you know what the
*minimum* information for constructing an object is. For example, look at
this class:
class Person {
private string name;
private int age;
public Person(string name) {
this.name = name;
}
public Person(string name, int age) {
this.name = name;
this.age = age;
}
public string Name {
get {
return this.name;
}
}
public int Age {
get {
return this.age;
}
set {
this.age = value;
}
}
}
You can choose to construct a new Person passing both the name and age as
arguments to the constructor, or just the name. But in all cases you *must*
provide the name. You can set the age later, when you have the data
available or when it changes.
I hope that clears it up,
-JG