Docsity

Design Patterns - Java and the Web - Lecture Slides, Slides of Java Programming

Partial preview of the text

Download Design Patterns - Java and the Web - Lecture Slides and more Slides Java Programming in PDF only on Docsity!

More Design Patterns

  • I am somewhat conflicted by this chapter as an instructor. While I believe that using design patterns is a critical skill for a professional programmer in an object-oriented environment, I am not sure how much emphasis it should have in an introductory course in programming.

Programming, not Design

  • The problem is that this course is identified as a programming course, and design is a secondary consideration.

What are patterns applied to?

These patterns are applied to:

  1. Programming Idioms
  2. Coding Idioms
  3. Data Structures
  4. Algorithms
  5. Protocols
  6. Development of new frames

What are patterns applied to?

  1. Use of existing Frameworks
  2. Analysis of models
  3. System Architecture
  4. Development Organization
  5. Development Process.

Course objective

  • In this course, I do not expect you to learn all the design patterns mentioned. However, I do expect you to develop a good understanding of a couple of patterns, and to have an intuitive sense of what a design pattern is, how it is described, and what its function is.

Key Patterns

  • Some patterns that are important are the Singleton pattern and Controller patterns, especially since many object-oriented programmers use the Model-View-Controller pattern as a programming paradigm. You should also identify some of the patterns discussed in the text as important based on your own interests.

Design Patterns

  • A Design Pattern is the one which typically shows the interactions and relationships between objects or classes without specifying the final applications or classes that are involved.

Design Patterns

  • Patterns are usually concerned with some kind of architecture.
  • Each pattern is a three-part rule, which expresses a relation between a certain context, a certain system of forces which occurs repeatedly in that context, and a certain software configuration which allows these forces to resolve themselves.

How are Design Patterns

different from Frameworks?

  • Design Patterns are more abstract than Frameworks.
  • Design Patterns are smaller architectural elements than Frameworks.
  • Design Patterns are less specialized than Frameworks.

How is a pattern different from

a class?

  • A pattern is not an implementation. It just describes when, why, and how to go about creating an implementation.
  • Some solutions are responsive for description via implementations such as classes, frameworks, tools that provide developers everything they would need to know. Even so, the code itself is not the pattern.

Session Facade

  • Session Facade is a design pattern used in developing Enterprise applications.
  • It is implemented as a high level component (like a Session EJB) and has all the interactions between low level components (like an Entity EJB).
  • It provides a single interface for the functionality of the application.

Session Facade Class Diagram

Session Facade

  • Performance
    • An Entity bean is equivalent to a row in the database. If the Entity beans were to be accessed directly, a network call would result for each row access.
    • On the other hand, a Session bean is equivalent to a stored procedure. Accessing a session bean that is co-located with an entity bean emulates accessing a row through a stored procedure.

Design patterns: Session Facade

  • Facade session bean with EJB 1.

EJB container

Entity Bean

Session facade

Web container

Session facade

Database

Entity Bean Entity Bean

Business logic

Business logic

Servlet

Servlet Presentation logic

Presentation logic

Communication layer

remote interface