I can understand why they are used, and I know that they DO help code maintainability but at the same time there are places where they are USELESS.
What’s the point of using getters/setters in this class? There is none, so why do it? You aren’t trying to encapsulate anything, you want both variables to be fully accessed. Adding get/set will only introduce overhead.
Why are people so inclined to use get/set in these situations?
public class Vector2f
{
public float x, y;
public Vector2f(float x, float y)
{
this.x = x;
this.y = y;
}
public Vector2f() {}
}
I’ve just read articles about why people should use getters and setters. The examples are so poor, it makes me wonder if there is any common sense left in this world.
Have the teachings of OOP gone so far as to brainwash the masses?
I think it’s about time for Sun to add properties (like in .NET, Python, etc…) to Java.