P5: Refactoring an Application
Due: Monday, October 21th, 12noon
is the source code of Notepad, which I
from trolling the internet. It is an example of a hacked program
-- it works, but has an awful design.
This assignment gives you a bit of practice to refactor an ugly program
into a less ugly program. (It needs much, much more to beautify
it -- if indeed it can be beautified).
I want you to create a NetBeans or Eclipse project (NetBeans move
method doesn't seem to work for me) of Notepad, and perform the following refactorings:
Hint: after each step:
- all fields of every class are private. This may mean that you have to add getters (and/or setters).
- make class Main to be a singleton. All method parameters of type Main should be removed.
- remove class Center, and appropriately distribute its functionality
- remove all unnecessary import declarations (there are quite a few of these) from all files
- in class Action, you will find the ugly expression
!n.getTextArea().getText().equals(fileContent)" in a number of places;
lift this expression into the boolean method standardTest().
- add functioning "close" method to the File Menu
And finally, answer this question:
why is this a good (or not so good) candidate for partitioning a
program into two parts: a GUI and its underlying MODEL?
- save your work
- make sure that your refactored program works
What to Submit
critical part of any design is clarity and
understandability. Hence, you will be graded on the clarity
of your project and its ability to work correctly. Sloppy code,
documentation, or anything that makes grading or understanding your
program difficult will cost you points! Beware, some of these
"beauty" points are subjective.
assignments/submissions will be accepted.