Java Reference
In-Depth Information
Once we have done the exercise described above, writing each class's interface is easy. We can
translate directly from the cards into Java. Typically, all classes should be created and method
stubs for all public methods should be written. A method stub is a placeholder for the method
that has the correct signature and an empty method body. 2
Many students find doing this in detail tedious. At the end of the project, however, you will
hopefully come to appreciate the value of these activities. Many software development teams
have realized after the fact that time saved at the design stage had to be spent many times over
to fix mistakes or omissions that were not discovered early enough.
Inexperienced programmers often view the writing of the code as the “real programming.”
Doing the initial design is seen as, if not superfluous, at least annoying, and people cannot wait
to get it over with so that the “real work” can start. This is a very misguided picture.
The initial design is one of the most important parts of the project. You should plan to spend at
least as much time working on the design as on the implementation. Application design is not
something that comes before the programming—it is (the most important part of ) programming!
Mistakes in the code itself can later be fixed fairly easily. Mistakes in the overall design can,
at best, be expensive to put right and, at worst, fatal to the whole application. In unlucky cases,
they can be almost unfixable (short of starting all over again).
13.2.2
User interface design
One part that we have left out of the discussion so far is the design of the user interface. 3 At
some stage, we have to decide in detail what users see on the screen and how they interact with
our system.
In a well-designed application, this is quite independent of the underlying logic of the applica-
tion, so it can be done independently of designing the class structure for the rest of the project.
As we saw in the previous chapters, BlueJ gives us the means of interacting with our application
before a final user interface is available, so we can choose to work on the internal structure first.
The user interface may be a GUI (graphical user interface) with menus and buttons, it can be
text based, or we can decide to run the application using the BlueJ method-call mechanism.
Maybe the system runs over a network and the user interface is presented in a web browser on
a different machine.
For now, we shall ignore the user-interface design and use BlueJ method invocation to work
with our program.
2
If you wish, you can include trivial return statements in the bodies of methods with non- void return
types. Just return a null value for object-returning methods and a zero, or false , value for primitive
types.
3
Note carefully the double meaning of the term 'designing interfaces' here! Above, we were talking
about the interfaces of single classes (a set of public methods); now, we talk about the user interface
what the user sees on screen to interact with the application. Both are very important issues, and unfor-
tunately the term interface is used for both.
 
Search WWH ::




Custom Search