Oliver Wong said:
I think the big problem actually is that the Java programming language
wasn't designed in such a way so as to make it easy to write methods which
return multiple return values. You're making a "hack" by returning just
one object (a list) which actually contains all the return values you
want, but this is fighting the language, so to speak.
Normally I wouldn't suggest this, since it's a long term solution, but
you seem to be sticking around these newsgroups, so here goes. Can you
give a grand overview of what your program does? I think there are some
fundamental design problems with it, perhaps because you come from a PHP
background.
Hi,
Yes one of my programs is a math program, which carries out an 'LU
decomposition' upon a matrix which has been supplied by the user (for
matrix here read 'array' - a matrix is simply a math term for a 2D array of
numbers). The decomposition returns three matrices upon completing the
routine - a P-matrix, L-matrix, and a U-matrix.
I think I said in an earlier post that the arrays (or matrices) were 3D -
they are and the reason they are 3D and not 2 is because they carry 'complex
numbers' which require a second field to represent them.
Sometimes though, under certain conditions, the P-matrix is not strictly
required, so a boolean value is also returned to 'flag' whether the P-matrix
is needed or not.
So, I am in the position of having to return three 3-dimensional arrays and
a boolean.
I could simply have used one array I suppose and just returned that (having
combined the three matrices into one single array), but that still leaves
the boolean...!
As for a problem with the design of the program, then I am just following a
standard algorithm to find LU decomps (in fact as far as I know there are
only two and they both produce multiple matrices)
I'm not saying that PHP is "bad", but that you have to think
differently in Java than you do in PHP. It's like when an English speaker
learns French and tries to use an expression that doesn't exist in French
(e.g. "What's up?" instead of "What's new?").
Very true and I see your point - Java is very different to PHP i think and
requires a paradigm shift in thinking.
Java is more object oriented than PHP, which is why you're receiving a
lot of suggestions to wrap your return values into an object and to return
just that one object.
yes I think I will go down the route of using an object wrapper and return
that