Re: This sort of thing might push me to Scala
Robert Sartin <[email protected]> Fri, 18 Dec 2009 11:21:14 -0600
| Newsgroups | gmane.comp.programming.language-of-the-year |
|---|---|
| Message-ID | <[email protected]> |
So, within the constraints of Java and your coding guidelines (hey, I
like to argue outside of the box and whether the box should be there
at all, but others have already done that), would it be reasonable to
create actual classes (named inner classes or standalone classes,
rather than anonymous ones) that implement Runnable and have the run()
method do what you need?
It probably increases your line and token counts a bit, but it
separates the noise out of the main code, which would look like:
runWithWaitCursor(new MethodEditorRunner(title, file));
and somewhere is something like:
class MethodEditorRunner implements Runnable {
public MethodEditorRunnable(title, file) {
// save title and file
}
public void run() {
new MethodEditor(title, file);
}
}
As an aside, I'm a little bothered by the fact that the MethodEditor
object appears to do all of its work as a side effect of being
created. I would consider rewriting that. In this case, it might be
possible to rework the MethodEditor class to implement Runnable and
move that work into a run() method, but it's hard to tell with the
limited information I have.
Regards,
Rob
> _,_._,___