Billy Sclater wrote:Thanks everybody, that's something for me to think about
Actually, I'm more interested in your colleague's use of the
word "magic".
Your code is an example of what we used to call "hard-coding", which means that it does only one thing. Now there's nothing wrong with "one thing" when it comes to
responsibility, but not when to comes to values, or things that might be equally easily supplied as
parameters, because it makes code "brittle" - by which I mean that if you want it to do
something else, you have to change the code. And that's generally
not a good idea.
Bear's suggestion is just one way to go in the case of filenames, but in the case of a
copy utility, it might be even better to simply supply them at runtime - ie, make them part of the '
args' you supply to your
main() method.
HIH
Winston