R
Roedy Green
Let us say you invent a generic method to create the header on a
webpage. Let's say it has a whacking huge number of parameters.
Now along comes a new heading that needs a wrinkle, one extra parm
passed. You could create a new method with N+1 parms, and have the old
N-parm method call it with a default.
Let's say this process continues. You end up with mess, and no way of
keeping track of what parameter is what.
So instead you do a textual search an replace of all calls in the
universe to add a default parameter to a N+1 parm method.
Now the calls get pretty ugly, lots of null, false, "". So when you
come to maintain them, you can't tell which parm is which.
How might such a problem be tackled? I had five ideas:
1. with keyword parameters. They can go in any order. Ones left out
get as standard default. The problem with that is, it requires a
major addition to Java syntax, and you can't proofread. You may
inadvertently leave out a crucial keyword, and you won't notice.
Further you code will get out of canonical order making it harder to
read and compare.
2. With an SCID/IDE that inserts temporary comments between positional
parameters to identify them. You can further click to see the full
javadoc on a parm.
3. With an SCID/IDE that has hoverhelp for a positional parameter.
4. With a SCID/IDE with a gather feature. It temporarily pulls
together all method calls in the universe into one page. You can then
more easily cross-compare them. It is like a lot of tiny scrolling
windows so you can see each call in context. The calls are labelled
with the class/method where they came from.
5. You do the call with a number of aux set up calls then a master
call. The master call would contain all the mandatory parms, and the
aux calls would be for various groups of related optional parms. This
is like a poor-man's keyword scheme.
What do you think? Any other approaches?
webpage. Let's say it has a whacking huge number of parameters.
Now along comes a new heading that needs a wrinkle, one extra parm
passed. You could create a new method with N+1 parms, and have the old
N-parm method call it with a default.
Let's say this process continues. You end up with mess, and no way of
keeping track of what parameter is what.
So instead you do a textual search an replace of all calls in the
universe to add a default parameter to a N+1 parm method.
Now the calls get pretty ugly, lots of null, false, "". So when you
come to maintain them, you can't tell which parm is which.
How might such a problem be tackled? I had five ideas:
1. with keyword parameters. They can go in any order. Ones left out
get as standard default. The problem with that is, it requires a
major addition to Java syntax, and you can't proofread. You may
inadvertently leave out a crucial keyword, and you won't notice.
Further you code will get out of canonical order making it harder to
read and compare.
2. With an SCID/IDE that inserts temporary comments between positional
parameters to identify them. You can further click to see the full
javadoc on a parm.
3. With an SCID/IDE that has hoverhelp for a positional parameter.
4. With a SCID/IDE with a gather feature. It temporarily pulls
together all method calls in the universe into one page. You can then
more easily cross-compare them. It is like a lot of tiny scrolling
windows so you can see each call in context. The calls are labelled
with the class/method where they came from.
5. You do the call with a number of aux set up calls then a master
call. The master call would contain all the mandatory parms, and the
aux calls would be for various groups of related optional parms. This
is like a poor-man's keyword scheme.
What do you think? Any other approaches?