06-04-2011, 10:43 PM
i everyone, I'm working on a summer coding project with few friends from school and we have a design issue that we need some input on.(The language is Java) We have for example a 2D vector class called Vector2. It has two properties float X, and float Y. When I was learning Java I was always told that these should be private and have getter and setter methods. The debate is now that if I want to say add up the x components of two vectors and set that to the x component of another vector we now have a bit of a mess. example
Java Syntax (Toggle Plain Text)
myNewVec.setX(vecA.getX() + vecB.getX());
If we had set the fields public we could have much cleaner syntax as follows:
Java Syntax (Toggle Plain Text)
myNewVec.x = vecA.x + vecB.x;
Java Syntax (Toggle Plain Text)
myNewVec.setX(vecA.getX() + vecB.getX());
If we had set the fields public we could have much cleaner syntax as follows:
Java Syntax (Toggle Plain Text)
myNewVec.x = vecA.x + vecB.x;
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
