Java-Three Layer Architecture Design

  • Abstraction
    • eliminate irrelevant details
    • ignore relevant detail which is not need for current task
    • generalize problem
      • reusable
      • handle more situations
  • Decomposition
    • divide larger task to small sub=parts
    • solve each sub-task with a module or more
    • combine those modules
    • each module need a specification of what sub-task do
      • develop when dividing
      • reason why module like this
      • final specification for combine
      • final specification used when solve problem
    • specification contain
      • signature
      • precondition
      • postcondition
      • return value
    • Guideline of Decomposition
      • Locality
        • keep related thing inside one class
      • Strong cohesion
        • everything inside one module should focus on same purpose
      • Weak coupling
        • minimize interaction between modules
        • if so, merge them or parts of them
        • each entities only know certain about others
        • how entities does job is hidden from other parts of system
        • each entities have own abstract specification
  • Sequence of Instructions fro Interactive System
    • read specification for what operation to do
    • determine what command do
    • if necessary, read in the data for the command
    • execute command
      • may be many part to do
        • exp. calc, get info from file….
      • separate it
        • I/O to interface
        • calc as a command and get-info as a command….
        • each command as a separate class(use command as object, called Command Pattern)
          • easy to add/remove command
          • do/redo/undo a command
          • can save command for later execution
          • send a command to where executed
    • output result
  • Class Classification
    • 1. entity class
      • basic data structure and methods
    • 2.container class
      • container of entities
    • 3. control class
      • main program and test
    • 4. interface class
      • control I/O
      • handle communication between system and entities
  • Three Layers
    • Presentation Layer
      • user Interface
        • Handle I/O
      • startup
        • Internalize System
          • active container
      • controller
        • determine next operation
        • obtain parameter
        • execute operation
        • handle result of operation
    • Domain Layer
      • commands
        • actual operation
        • handle error input/output
          • invoke a mutator for error message, store in a field of command
          • output it if error happened
          • check commandStatus class in assignment
      • container
        • data storage of entities
    • System Layer
      • entities
        • actual data structure and their own methods

留下评论