ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Example: Print Shop | 75

The class structure is very similar to the minimalist example shown in Figure 2-3.


The products will be print jobs that will be created and the creators will be the print


centers (see class diagram in Figure 2-6).


Product Classes: Print Jobs


The product classes don’t do anything at this point, but in a real application they will


initiate billing and dispatch print jobs to a print server. The print job classes belong


to the printcenters package. Example 2-8 shows the IPrintjob interface that


declares a parameterized method calledstart( )that takes a file name of a document


to print.


Figure 2-5. Project window for the print shop example


Figure 2-6. Class diagram for the print shop example


Client PrintCenter
print()
createPrintjob()

print() {
..
printjob=createPrintjob()
..
IPrintjob }

LowVoIPrintCenter
factoryMethod()

InkjetPrintjob

WorkgroupPrintjob HighVoIPrintCenter
createPrintjob()
Free download pdf