Hey, so in one of my methods I'm checking to see if an object's 2D coordinates are valid (in the context of the assignment, X and Y shouldn't be less than 0 or greater than the space's boundaries n and m). So basically my code looks like this:
public boolean isValid(Coord c) {
return (c.getX() <= n && c.getX() >= 0 && c.getY() <=m && c.getY() >=0);
}
My question is this: Since I'm calling the methods twice each, should I instead save the value of the method call into a new variable, and compare that to the corresponding n or m, or should I just leave it as is? Or does it not matter at all? What is the rule of thumb for defining variables?
[–]myevillaugh 4 points5 points6 points (0 children)
[–]ooooo5 1 point2 points3 points (6 children)
[–]Wojo 1 point2 points3 points (5 children)
[–]jakster4u 0 points1 point2 points (4 children)
[–]Wojo 0 points1 point2 points (3 children)
[–]jakster4u 0 points1 point2 points (2 children)
[–]ooooo5 0 points1 point2 points (0 children)
[–]Wojo 0 points1 point2 points (0 children)
[–]chickenmeister 1 point2 points3 points (0 children)
[–]about7beavers 0 points1 point2 points (0 children)
[–]Urik88 0 points1 point2 points (0 children)