J2EE Architecture and Design Patterns by q97T73d


									J2EE Architecture and Design Patterns

                     Student: Fang Fang
                     Advisor: Dr. Glen Qin
                       Date: 05/14/2005

●   Introduction to “Architecture”
●   J2EE Architecture Diagram
●   Distributed Programming Serviced
●   Modular-Based Development
●   J2EE Application Deliverable
●   J2EE Standards
●   Patterns Arose from Architecture
●   Gang of Four Patterns
●   Q&A
EJB Distributed Nature (II)
Deployment Descriptor Sample

            This role represents everyone who is allowed full access
            to the Cabin EJB.
Patterns Arose from Architecture and
Anthropology - Christopher Alexander

●   Is quality objective?
●   How do we get good quality repeatedly?
●   Look for the commonalities
●   ...especially commonality in the features of the problem to
    be solved
Moving from Architectural to Software
Design Patterns

●   Adapting Alexander for software
●   The Gang of Four did the early work on design patterns
    (Gamma, Helm, Johnson, Vlissides)
Key Features of Patterns

Item                          Description
Name                         All patterns have a unique name that identifies them
Intent                       The purpose of the pattern
Problem                       The problem that the pattern is trying to solve
Solution                      How the pattern provides a solution to the problem in the context
                              in which it shows up
Participants                 The entities involved in the pattern
and collaborators
Consequences                  The consequences of using the pattern. Investigates the forces at
                              play in the pattern
Implementation                How the pattern can be implemented
Generic structure             A standard diagram that shows a typical structure for the pattern
Enumerate GoF Patterns

Creational Patterns   Structural Patterns   Behavioral Patterns

Abstract Factory      Adapter               Chain of Responsibility
Builder               Bridge                Command
Factory Method        Composite             Interpreter
Prototype             Decorator             Iterator
Singleton             Facade                Mediator
                      Flyweight             Memento
                      Proxy                 Observer
                                            Template Method
    Abstract Factory Pattern
        “Provide an interface for creating families of related or dependent
         objects without specifying their concrete classes." - GoF
                                                                     class ApControl {
           Problem                        Solution                     . . .
                                                                       public void doDraw() {
                                                                         . . .
A Switch to Control Which Driver to Use                                  myDisplayDriver.draw();
class ApControl {                                                      public void doPrint() {
  . . .                                                                  . . .
  public void doDraw() {                                                 myPrintDriver.print();
    . . .                                                              }
    switch (RESOLUTION) {                                            }
      case LOW:
        // use lrdd                                                  abstract class ResFactory {
      case HIGH:                                                       abstract public DisplayDriver getDispDrvr();
        // use hrdd                                                    abstract public PrintDriver getPrtDrvr();
    }                                                                }
  public void doPrint() {                                            class LowResFact extends ResFactory {
    . . .                                                               public DisplayDriver getDispDrvr() {
    switch (RESOLUTION) {                                                 return new LRDD();
      case LOW:                                                         }
        // use lrpd                                                     public PrintDriver getPrtDrvr() {
      case HIGH:                                                          return new LRPD();
        // use hrpd                                                     }
    }                                                                }
  }                                                                  class HighResFact extends ResFactory {
}                                                                    ...
The Facade Pattern

●   “Provide a unified interface to a set of interfaces in a subsystem.
    Facade defines a higher-level interface that makes the subsystem
    easier to use.” - GoF
       Problem                             Solution
Stragegy Pattern

  “Define a family of algorithms, encapsulate each one, and make
   them interchangeable. Strategy lets the algorithm vary
  independently from clients that use it.” - GoF

          Problem                            Solution
●   Q&A
●   Thank you!!

To top