Getter-Setter Pattern Considered Harmful
The Problem
Many developers (like myself) who started their careers with OOP (Java, C#, ...) during the last decades will look at this
code and find nothing wrong about it at first sight.
public class Person {
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
In fact, everything's wrong with this code fragment. However, we have ...
Read more at wolfgang-ziegler.com