feel free to tear it apart
Ok...
A program should tell a story. This program doesn't tell its story very well. It starts out being very vague about what it's doing by creating a FileProcessor object and then calling that object's
copyFile() method. Nothing else in that code gives the reader any kind of context on what they should expect, except the error handling boilerplate around the call to
copyFile(). What file is being copied? Where is it getting copied to? The code is very mysterious-looking.
When you get to the copyFile() method, you realize that there's really more to it than what the name suggests. It's doing more that just "copy a file". The JavaDocs explain enough but we'll hold off on talking about JavaDocs until we define a better organization of the code.
The copyFile() method does too many things. First, it does user input. That should be separate. The name
FileProcessor is also vague whereas the JavaDocs are very specific. If the JavaDocs fully explain the reason for this class' existence, then maybe you can find a name that better reflects that purpose.
Honestly, if all I needed to do was copy one file to another then merge it with a third, I'd just do this with static methods.
This would be the pseudocode:
main code:
get filename to copy from
get filename to copy to
get filename to append
copyFile(source, dest)
append(dest, appendFile)
copyFile(from, to):
fromFile = openFile(from)
toFile = createFile(to)
toFile.write(fromFile.contents())
close all files
append(main, other)
mainFile = open(main)
appendFile = open(other)
mainFile.append(appendFile.contents())
close all files
The semantics of the appendFile() method are also important. Your
appendFile() method has source and output. That's not a very good story either. Does source identify the content that you're appending or the content that you're appending to? What is the output? If I take that name at face value, it would seem like it's supposed to identify the result of the appendFile operation. In that case, we have three things in play: the thing we're appending to (Thing1), the thing we're appending (Thing2), and the result of appending Thing2 to Thing1, Thing3. But there are only two parameters. Which one are we missing? This is confusing.
If I'm appending one thing to another, I would take it to mean that the "one thing" is what is being
appended to "another" thing. That is, if I append an index to a book, then the index becomes part of the book. I won't get another book, I'll just get the same book, only now with an index.
I would expect the appendFile() method to operate in a similar manner. So that's why I have a
main parameter and an
other parameter and the
appendFile simply modifies
main by appending
other to it.