mcsee/clean-code-cookbook

Wrong code snippet in 3.3

Opened this issue · 0 comments

In the book, the code snippet associated with part 3.3 (Removing Setters from Objects) seems to be a Java code:

public class Point {
    protected int x;
    protected int y;

    public Point() { }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }
}

Point location = new Point();
// At this moment, it is not clear which points are represented
// It is coupled to the constructor decision
// Might be null or some other convention

location.setX(1);
// Now you have point(1,0)

location.setY(2);
// Now you have point(1,2)

// If you are setting essential properties, move
// them to the constructor and remove the setter methods

However, in the repository, there is a Python code that is completely unrelated to the examples in the book https://github.com/mcsee/clean-code-cookbook/tree/main/Code/Chapter%2003%20Anemic%20Models/3.03%20Removing%20Setters%20from%20Objects