Java Reference
In-Depth Information
2. Enter lines 164 through 196 as shown in Figure 9-32 on page 570.
TextPad displays the code for the validate() method in the coding window
(Figure 9-34). Comments again are used to document the code.
throws exception
for invalid password
ArrayList isEmpty()
method called
ArrayList size()
method called
validate() method
validates whether
password value
matches current
password
ArrayList get()
method called
throws exception
for expired
password
FIGURE 9-34
throws exception if
no password exists
Notice that both the set() and validate() methods are relatively short.
It is not uncommon in object-oriented code to have many smaller methods
rather than fewer, larger ones. This contributes to making the code more
understandable and easier to maintain.
 
Search WWH ::




Custom Search