1 / 40

George Blank University Lecturer

George Blank University Lecturer. CS 602 Java and the Web. Object Oriented Software Development Using Java Chapter 10. More Design Patterns.

lorimer
Download Presentation

George Blank University Lecturer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. George Blank University Lecturer

  2. CS 602Java and the Web Object Oriented Software Development Using Java Chapter 10

  3. 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.

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

  5. Key to Design • Craig Larman, the author of Applying UML and Patterns, has stated that the most important skill in Object-Oriented Design is assigning responsibility to objects. Understanding that simple statement helps to clarify Design Patterns. Most of them answer the question; “Which object should be assigned this responsibility?”

  6. 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

  7. What are patterns applied to? 7. Use of existing Frameworks 8. Analysis of models 9. System Architecture 10. Development Organization 11. Development Process.

  8. Creator Patterns • For example, the first group of patterns discussed in Chapter 10 are creator patterns. Primarily, a creator pattern is a tried and tested answer to the question; “If I need to create a new instance of an object, what object should have the responsibility for instantiation?”

  9. 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.

  10. 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.

  11. Chapter 10 Patterns • Abstract Factory • Prototype • Builder • Command • Adapter

  12. 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.

  13. 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.

  14. Design Patterns • The design pattern identifies the participating classes and their instances, their roles and collaborations, along with the distribution of responsibilities. • Each design pattern focuses on a particular object-oriented design problem. • It describes when it applies, whether or not it can be applied in view of other design constraints.

  15. 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.

  16. 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.

  17. Session Façade, Business Delegate and Model-View-Controller Design Patterns Praveen Mula Subba Reddy Daka

  18. 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.

  19. Session Facade Class Diagram

  20. Sequence diagram before and after adding Session Facade

  21. 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.

  22. remote interface Servlet Session facade Entity Presentation Business Bean logic logic Entity Session facade Bean Servlet Business Presentation Database Entity logic logic Bean Web container EJB container Communication layer Design patterns: Session Facade • Facade session bean with EJB 1.1

  23. Local interface Servlet Session facade Entity Presentation Business Bean logic logic Entity Session facade Bean Servlet Business Presentation Database Entity logic logic Bean Web container EJBcontainer Design patterns: EJB 2.0 local • Session facade with EJB 2.0 local interface Entity Beans

  24. Session Facade • Reusability • The session bean layer is powerful because it externalizes all business logic from the entity beans. This means the entity beans contain data and data-related logic only. • This promotes high re-use of entity beans. • Data abstraction layer • The session bean layer is a facade. The particular way the session bean persists (via JDBC directly or via entity beans) is an implementation detail of the session bean.

  25. Benefits of Session Facade • Lower Network overhead • Shorter execution time • Short and local Transaction • Higher Concurrency • Lower Coupling • Better Reusability and maintainability

  26. Business Delegate • The Business Delegatehides the underlying implementation details of the business service, such as lookup and access details of the EJB architecture. • The Business Delegate pattern manages the complexity of distributed component lookup and exception handling,

  27. Business Delegate • Business Delegate may adapt the business component interface to a simpler interface for use by views. • It reduces coupling between client and system’s business services and possibly shields client from volatility in implementation of business service API.

  28. Business Service Component A business service component implements the actual business logic. Some examples of the business service components are stateless session EJB and entity EJB, a CORBA object or an RPC server

  29. Business Delegate Class Diagram Note: POJO is “Plain Old Java Object”

  30. Business Delegate Sequence Diagram

  31. Business Interface Pattern • Business Interface pattern allows us to provide a business-specific interface for interacting with session beans.

  32. Business Delegate and Business Interface patterns • The Business Interface pattern defines the business logic available for use while the Business Delegate pattern provides access to logic without introducing a dependency on the implementation technology.

  33. Model-View-Controller (MVC) • The goal of a Model-View-Controller design pattern is to achieve decoupling among the software components that are responsible for encapsulating business functions, presenting the content and controlling the navigation.

  34. Model / view / controller (MVC) (displays data) View { Model m; Controller c(&m); View v(&c); } (mediates) Controller (holds data) Model calls Register() Main Create() View Create() Register() Create() Controller Model

  35. MVC (cont.) 1 * Subject Register(Observer) Unregister(Observer) NotifyAll() Observer virtual OnUpdate() for all o in observers { o.OnUpdate() } Controller View virtual OnUpdate()

  36. MVC using Struts

  37. Bibliography • Jia, Xiaoping, Object Oriented Software Development Using Java. Addison Wesley, 2003 • Larman, Craig, Applying UML and Patterns, 3rd Edition, Prentice Hall, 2002 • Cooper, James, The Design Patterns Java Companion, IBM Thomas J. Watson Research Center, 1998

  38. Online Resource • A good introduction to patterns for Java developers is the free on-line book by James Cooper of IBM at http://www.patterndepot.com/put/8/JavaPatterns.htm

  39. Other Web References: • http://www.exciton.cs.rice.edu/JAvaResources/DesignPatterns/default.htm • http://en.wikipedia.org/wiki/Design_pattern_(computer_science) • http://www.cmcrossroads.com/bradapp/docs/patterns-intro.html#KindsOfDesignPatterns • http://www-128.ibm.com/developerworks/library/j-ejb1022.html • http://www.corej2eepatterns.com/Patterns2ndEd/BusinessDelegate.htm • http://www.allapplabs.com/j2ee_design_patterns/j2ee_design_patterns_business_delegate.htm

  40. References • http://java.sun.com/blueprints/patterns/SessionFacade.html • http://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html • http://www.jguru.com/ • http://www.javaworld.com/

More Related