M
Mr Smith
Hello,
In a table, i have various object. Right now, i'm writing the Double object code. But in Java (AFAIK) you can't overload operator, so, what is the best on a dummy operation: [i, j] += [i, j + 1]
1/
set(i, j, new Double(((Double)get(i, j)).doubleValue() + ((Double)get(i, j + 1)).doubleValue()))
Simply awful to read, it's just an addition here...
2/
setdouble(i, j, getdouble(i, j) + getdouble(i, j + 1))
Could be ok, but it needs to put the casts in a lot of getters/setters, heavy work.
3/
set(i, j, Op.addDouble(get(i, j), get(i, j + 1)))
with
static addDouble(Object a, Object b) {
double c = ((Double)a).doubleValue();
double d = ((Double)b).doubleValue();
return new Double(c + d);
}
What is you rpersonnal choice? What are the pros and cons?
Thanx for your advices
In a table, i have various object. Right now, i'm writing the Double object code. But in Java (AFAIK) you can't overload operator, so, what is the best on a dummy operation: [i, j] += [i, j + 1]
1/
set(i, j, new Double(((Double)get(i, j)).doubleValue() + ((Double)get(i, j + 1)).doubleValue()))
Simply awful to read, it's just an addition here...
2/
setdouble(i, j, getdouble(i, j) + getdouble(i, j + 1))
Could be ok, but it needs to put the casts in a lot of getters/setters, heavy work.
3/
set(i, j, Op.addDouble(get(i, j), get(i, j + 1)))
with
static addDouble(Object a, Object b) {
double c = ((Double)a).doubleValue();
double d = ((Double)b).doubleValue();
return new Double(c + d);
}
What is you rpersonnal choice? What are the pros and cons?
Thanx for your advices