01 November, 2006

Design Pattern: Book-MVC Project

Change Log:
  1. Downgrade to JAVA 1.4
  2. Add new button "Save Page as HTML", you can save the page to html now.
  3. Add new package "app", put class "BookDisplayer" inside.
  4. Add new package "layout", use Strategy pattern inside.
    • There are two layout generator:
      • PlainTextLayoutGenerator
      • HTMLLayoutGenerator
  5. Add new package "factory"
    • class "FormatterFactory" can provide different formatter to component, use Singleton Pattern.
  6. Add new class "BookHTMLPrinter" into control package, which can create a html file.
Implementation:
  1. layout package
    • Interface "Composition"
      • method "dolayout" will use the current layout generator to generate the component's layout.
    • Interface "Page"
      • defined the basic method for page
        • setPageWidth( int w )
        • setPageHeight( int w )
        • getPageWidth()
        • getPageHeight()
        • getPageId()
        • insertline(String line)
        • getContent()
    • Interface "LayoutGenerator"
      • method "compose" will use the formatter to construct the pages, and return a list the page.
    • Class "BookComposition"
      • implemented interface "Composition".
      • have a list of compoenets.
      • have a LayoutGenerator's reference which point to the current layout. generator.
    • Class "HTMLPage"
      • implemented interface "Page".
      • generate page in html formate.
    • Class "PlainTextPage"
      • implemented interface "Page".
      • generate page in plain text foramt.
    • Class "PlainTextLayoutGenerator"
      • implemented interface "LayoutGenerator".
      • generate pages with fixed line width, and page height.
    • Class "HTMLLayoutGenerator"
      • implemented interface "LayoutGenerator"
      • generate pages with html tag.

No comments: