Do you think it is bad practice to create public variables instead of using setter/getter methods? Why? I'm referring to a class and how the variables of that class are set:
Public Variable
class someClass {
public variable;
}
localClass = new someClass();
localClass->variable = "CodeCall";
Setter/Getter
class someClass {
private variable;
function setVariable(value) {
this->variable = value;
}
function getVariable(value) {
return this->variable;
}
}
localClass = new someClass();
localClass->setVariable("CodeCall");
What do you think of the C# ability to auto-implement setter/getters:
[highlight=c#]
public class Point {
public int x { get; set; }
}[/highlight]


Sign In
Create Account

Guest_Jordan_*
Back to top











