vendredi 11 mars 2016

Proxy design pattern

I am looking at a part of code for the design pattern proxy. On row 01 and 02 he comments, and I don't really get it. I see the creates an ATMMachine object part but I don't understand the destroy part. What does he mean?

01  // In this situation the proxy both creates and destroys
02  // an ATMMachine Object
03   
04  public class ATMProxy implements GetATMData {
05   
06      // Allows the user to access getATMState in the
07      // Object ATMMachine
08       
09      public ATMState getATMState() {
10           
11          ATMMachine realATMMachine = new ATMMachine();
12           
13          return realATMMachine.getATMState();
14      }
15   
16      // Allows the user to access getCashInMachine
17      // in the Object ATMMachine
18       
19      public int getCashInMachine() {
20           
21          ATMMachine realATMMachine = new ATMMachine();
22           
23          return realATMMachine.getCashInMachine();
24           
25      }
26       
27  }

Aucun commentaire:

Enregistrer un commentaire