Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 2. Factory Method Pattern > Example: Print Shop

2.5. Example: Print Shop

Let's develop an example application to dispatch print jobs at a hypothetical print shop (think copy center with printers). Think of the shop as a place where customers bring what they want to print on portable media. The clerk at the counter will initiate a print job on the computer for dispatch and billing, based on the type of print job. We will build the application in Flash and ActionScript 3.0 as a generic example to illustrate the utility of the factory method pattern.

Our print shop is a small time operation with only two printers. We have a workgroup printer and an inkjet that prints in black and white. In order to streamline operations, the manager has a bright idea to create separate print centers in the shop. One print center will handle high-volume jobs that will be sent to the workgroup printer. The other will handle low-volume jobs that will be dispatched to the inkjet. We design the print shop application using the factory method pattern, as we had heard somewhere that it allows for flexibility and expansion. We are hoping to make a profit and add more printers in the future. Figure 2-5 shows the class structure for the print shop example.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial