??????????????????????????????????????????????????????????????????????“????”?????“??”??????????????????????????????????????????????????????????????????????????????????????о?????????????????棬???????????????????????????????????????????????????????????“???2????????????????????????”?????????????????????????????????????????????????????????????????????????????????????????μ????顣
??????????????“…”??????????????????????????????????????????????

String username = "robertmiller";

String password = "java.net";

ICustomerAccount ca = new CustomerAccount(username?? password);

if(ca.isRequestedUsernameValid() && ca.isRequestedPasswordValid()) {

   ...

   ca.createNewActiveAccount();

   ...

}

??????????棬??Щ?????????????????????????????????????????????????????????????????????д????????????????磬???????????????????????????????????????????????Web????????????????????????????????

//Constructor that performs too much work!

public CustomerAccount(String username?? String password)

                  throws CustomerAccountsSystemOutageException {

 

 this.password = password;

 this.username = username;

 this.loadAccountStatus();//unnecessary work.

}

//Remote call to the database or web service.

public void loadAccountStatus()

                  throws CustomerAccountsSystemOutageException {

 ...

}

?????????????????????????????????????????????????????????????????????????????????á?

String username = "robertmiller";

String password = "java.net";

try {

 //makes a remote call

 ICustomerAccount ca = new CustomerAccount(username?? password);

 //makes a second remote call

 ca.loadAccountStatus();

} catch (CustomerAccountsSystemOutageException e) {

 ...

}