• Save
Ajs 2 a
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,038
On Slideshare
991
From Embeds
47
Number of Embeds
2

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 47

http://niitcourseslides.blogspot.in 45
http://niitcourseslides.blogspot.com 2

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. UML Diagrams And Design PatternsPre-assessment Questions 1. Identify the correct statement for synchronous integration. a) Request invocation thread of the application does not block the processing of the application b) Supports loose coupling of applications c) Sends message to a request invocation thread and continues d) Supports the request/response interaction model ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 1 of 51
  • 2. UML Diagrams And Design PatternsPre-assessment Questions 1. Consider the statements: Statement A: Queue-based communication involves a message sender sending a message to a message queue that is responsible for processing the message. Statement B: Queue-based communication involves a message sender sending a message to a message queue that is responsible for dispatching the message to a receiver. Identify the correct option. a) Statement A is True and statement B is False. b) Statement A is False and statement B is True. c) Both, statements A and B, are True. d) Both, statements A and B, are False. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 2 of 51
  • 3. UML Diagrams And Design PatternsPre-assessment Questions • Which level of integration uses the integration frameworks and application programming interfaces to integrate two applications? a) Data level b) Application interface level c) Method level d) User interface level ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 3 of 51
  • 4. UML Diagrams And Design PatternsPre-assessment Questions 1. Being a System Analyst, you are responsible for integrating a J2EE application with a legacy system. You need to integrate the J2EE application and legacy system using their similar functional methods. Which option enables you to perform the specified task? a) User interface level integration b) Data level integration c) Method level integration d) Application interface level integration 2. Which technique defines a standard architecture for connecting a J2EE application server with different enterprise information system? a) Java native interface b) CORBA c) Web services d) J2EE Connector Architecture ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 4 of 51
  • 5. UML Diagrams And Design PatternsSolutions to Pre-assessment Questions: 1. d. Supports the request/response interaction model 2. b. Statement A is false and statement B is true 3. b. Application interface level 4. c. Method level integration 5. d. J2EE Connector Architecture ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 5 of 51
  • 6. UML Diagrams And Design PatternsObjectives In this lesson, you will learn to: • Model J2EE applications using UML diagrams • Identify the need for design patterns • Use creational design patterns ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 6 of 51
  • 7. UML Diagrams And Design PatternsModeling J2EE Applications Using UML • Case study: • NewTech Inc. is a retail bookstore that sells books of different categories such as science & technology, medicine, astronomy, novels, and children books. • As a part of its expansion plan, NewTech Inc. wants to go online and create an Online Bookstore System to attract customers from all over the globe. • Consider that NewTech Inc. names it online system as Online Bookstore System. The Website of the Online Bookstore System should list the books according to the categories that the books belong to. • The users of the Website should be able to browse through a catalog of books that is made available to them on the Website. Each book selected by the user should be listed in the user’s shopping cart. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 7 of 51
  • 8. UML Diagrams And Design PatternsModeling J2EE Applications Using UML (Contd.) • Case study (Contd.): • The Website of the retail bookstore should support two kinds of users: registered and unregistered. The Website should allow the unregistered user to browse through the online retail bookstore and view the details of the books. • In addition, the unregistered users should be allowed to add books to their shopping cart. However, only the registered users should be allowed to make an online purchase. • Moreover, the registered users should have a different view of the retail bookstore, which includes informational messages customized to their interests. • The Website of NewTech Inc. should also sell books to its various retail stores. The company has an enormous market following and therefore, the Website of the company should be scalable enough to support large number of page hits per day. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 8 of 51
  • 9. UML Diagrams And Design PatternsModeling J2EE Applications Using UML (Contd.) • The UML Diagrams that can be used to represent the structure and design of an enterprise application are: • Use case diagrams • Class diagrams • Package diagrams • Sequence diagrams • Collaboration diagrams • State diagrams • Activity diagrams • Component diagrams • Deployment diagrams ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 9 of 51
  • 10. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Use Case Diagram • Depicts the various operations that a system performs. • Contains use cases, actors, and their relationships. • Elements of a Use Case Diagram are: • Use Cases: Describe the behavior of a given system in textual format. • Actors: Represent the coherent set of roles that the users of a given system play while interacting with the use cases. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 10 of 51
  • 11. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Use Case Diagram (Contd.) • Elements of a Use Case Diagram are (Contd.): • Relationships: Represents the interaction between the actors and the use cases. The two types of relationships are: • Extend: Indicates that an existing use case is extended by additional behavior to obtain another use case. • Include: Indicates that the functions of one use case are included in the functions of the other. • System boundary: Defines the limits of the given system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 11 of 51
  • 12. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Use Case Diagram (Contd.) • Analyzing the Use Cases and Actors • Use Case diagram for the Online Shopping System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 12 of 51
  • 13. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Use Case Diagram (Contd.) • A use case specification document includes information, such as: • Actors: Specifies the participants of use cases. • Pre-conditions: Specifies the prerequisites to be met. • Post-conditions: Specifies the actions to be performed. • Basic flow: Lists the basic events that will occur when a use case is executed. • Alternative flows: Lists the subsidiary events that occurs in use case. • Special Requirements: Specifies the success and failure scenarios of business rules for the basic and alternative flows of events. • Use case relationships: Specifies the relationships that exist between the various use cases. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 13 of 51
  • 14. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Class Diagram • Represents the static design view of a system. • Includes a set of classes and interfaces along with the collaborations and relationships among the classes and interfaces. • The three types of classes that realize the behavior specified in the use case are: • Boundary class: Represents the interface between the actors and the given system. • Control class: Represents the use case logic and coordinates with other classes in the given system. • Entity class: Manages the information that a given system requires to provide a specific functionality. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 14 of 51
  • 15. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Class Diagram (Contd.) • Elements of a Class Diagram are: • Class: Represents an entity of a given system that provides an encapsulated implementation of business functionality for a given system. • Interface: Represents an entity of a given system that provides only the declaration of implementing business functionality. • Relation: Defines a logical connection between classes and interfaces of a given system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 15 of 51
  • 16. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Class Diagram (Contd.) • Class diagram for the Online Shopping System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 16 of 51
  • 17. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Package Diagram • Represents the grouping of related boundary, control, and entity classes of a given system. • Is similar to namespaces such that you can store classes with the same name in two different packages. • Elements of a Package Diagram are: • Packages: Refer to the grouping of similar elements. In J2EE environment, you group the classes with similar function in a package. • Relationships: Define a logical connection between various packages in a given system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 17 of 51
  • 18. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Package Diagram (Contd.) • Package diagram for the Online Bookstore System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 18 of 51
  • 19. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Sequence Diagram • Represents the interaction between the objects of a system in the form of messages in a sequence by time. • Depicts the dynamic behaviour of a given system. • Elements of a Sequence Diagram are: • Objects: Refer to an instance of a class. • Messages: Refer to the interaction between the various objects in the sequence diagram. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 19 of 51
  • 20. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Sequence Diagram (Contd.) • User login session sequence diagram for the Online BookStore System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 20 of 51
  • 21. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Collaboration Diagram • Represents the interaction between objects of a system in the form of messages. • Elements of a Collaboration Diagram are: • Objects: Refer to an instance of a class. • Messages: Refer to the interaction between the various objects as arrows in the collaboration diagram. . • Relations: Refer to the line associated with the objects of a given system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 21 of 51
  • 22. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Collaboration Diagram (Contd.) • User login session collaboration diagram for the Online BookStore System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 22 of 51
  • 23. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using State Diagram • Shows how the object of a system reacts when an event occurs. • Depicts the business flow of an object of a given system. • Elements of a State Diagram are: • Initial state: Refers to the first activity in a flow and is represented by a solid circle. • State: Refers to the state of an object at a specific instance of time. • Transition: Refers to the transition from one state to another and is represented by an arrow. • Event/Action: Refers to a user- or system-generated action that causes a transition to occur. • Final state: Refers to the last activity in a flow and is represented by a bull’s eye symbol. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 23 of 51
  • 24. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using State Diagram (Contd.) • User login session state diagram for the Online BookStore System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 24 of 51
  • 25. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Activity Diagram • Represents the dynamic view of a system that depicts the flow of control of objects from one activity to another. • Represents the business and operational workflows of a given system. • Elements of an Activity Diagram are: • Initial Activity: Refers to the first activity in a flow and is represented by a solid circle. • Activity: Refers to an action in a flow and is represented with a rectangle with rounded corners. • Decisions: Refers to the business logic where a decision is taken. • Final Activity: Refers to the last activity in a flow and is represented by a bull’s eye symbol. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 25 of 51
  • 26. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Activity Diagram (Contd.) • Order processing activity diagram for the Online BookStore System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 26 of 51
  • 27. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Component Diagram • Represents the grouping of packages and other components of a system along with their relationship with each other. • Represents the implementation of a given system. • Elements of a Component Diagram are: • Components: Refer to the entities that interact with each other in a given system. • Class/Interface/Object: Represents entities of a given system that forms a part of the component. • Relation/Association: Defines a logical connection between various components of a given system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 27 of 51
  • 28. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Component Diagram (Contd.) • Order processing component diagram for the Online BookStore System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 28 of 51
  • 29. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Deployment Diagram • Represents the configuration of run-time processing nodes and the components that reside on the node. • Provides a complete deployment environment for the given system, which is easy to comprehend. • Elements of a Deployment Diagram are: • Nodes: Represent the elements that provide an execution environment for the various components of a given system. • Relation: Represents the interconnection between various nodes of a given system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 29 of 51
  • 30. UML Diagrams And Design PatternsModeling J2EE Applications Using UML(Contd.) • Using Deployment Diagram (Contd.) • The deployment diagram for the Online BookStore System: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 30 of 51
  • 31. UML Diagrams And Design PatternsCreating a UML Diagram • Problem Statement • MetalTech US Engineering Inc. has an online product information system for its product designers. The product designers are located in different parts of country. The products are identified as metallic and non-metallic products. The information about a product includes attributes, such as product_id, product_name, product_type, and product_picture. A collection of assembled products form an assembly, which is identified by the attributes, assembly_id, and assembly_name. In the product information system, the part forming an assembly is known as Bill of Material (BOM). While creating the BOM, the product designer at the server end can add and remove the product parts from an assembly, as the structure of assemblies change frequently. Draw the use case diagram, class diagram, and sequence diagram for modeling the online product information system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 31 of 51
  • 32. UML Diagrams And Design PatternsCreating a UML Diagram (Contd.) • Solution 1. Identify use cases. 2. Identify actors. 3. Draw use case diagram. 4. Draw class diagram. 5. Draw sequence diagram. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 32 of 51
  • 33. UML Diagrams And Design PatternsOverview of Patterns • Patterns • Is a proven solution to a problem in a given context. • Is first verified several times in the real-world systems to be actually called a pattern. • Promotes reuse of software concepts and technologies, which make you work faster and efficiently. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 33 of 51
  • 34. UML Diagrams And Design PatternsOverview of Patterns (Contd.) • About GoF’s Design Patterns • The four elements of GoF’s design patterns are: • Pattern name: Identifies a pattern. • Problem: Describes when to apply a pattern and the context in which to apply the pattern. • Solution: Describes a pattern as a template, which can be applied to different contexts. • Consequences: Describes the pros and cons in applying the pattern in a certain context. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 34 of 51
  • 35. UML Diagrams And Design PatternsOverview of Patterns (Contd.) • About GoF’s Design Patterns (Contd.) • The advantages of using design patterns are: • Allows reusing the experience of predecessors. • Communicates the knowledge gained from experience. • Establishes common terminology for problems. • Provides solutions to real-world problems. • Captures knowledge and documenting best practices for a domain. • Documents the decision along with the rationale that leads to the solution. • Describes the circumstances, influences, and the resolution of a solution. • Facilitates design modifications, documentation, and understandability of a software system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 35 of 51
  • 36. UML Diagrams And Design PatternsOverview of Patterns (Contd.) • Types of GoF’s Design Patterns • The three types of design patterns are: • Creational design patterns: Provide techniques for creating objects • Structural design patterns: Describe the composition of objects and their organization. • Behavioral design patterns: Provide guidelines for enabling communication among objects of a given system. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 36 of 51
  • 37. UML Diagrams And Design PatternsOverview of Patterns (Contd.) • Creational Design Patterns • Supports the creation of class instances. • Allows instances of classes to be created, without the need to identify the class type by having the subclass of the class create the objects. • Hides the details of the class to be instantiated from the calling class, by using an abstract class. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 37 of 51
  • 38. UML Diagrams And Design PatternsCreational Design Pattern • Abstract Factory Pattern • Provides an interface to create families of related or dependent classes without declaring their concrete classes. • Consists of an abstract class along with a couple of subclasses that provide the implementations of the abstract class. • Allows the clients to use the classes only through their abstract classes. • Advantages of using abstract factory pattern are: • Isolates the implementation of concrete classes from the user. • Enables easy exchange of families of objects. • Ensures consistency among the families of objects. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 38 of 51
  • 39. UML Diagrams And Design PatternsCreational Design Pattern (Contd.) • Builder Pattern • Separates the construction of a complex object from its representation to enable the same construction process to create different objects. • Allows a client object to create a complex object by specifying only its type and content. • Defines an interface to create an object, but allows the subclass to decide which class to instantiate for the creation of an object. • Enables you to: • Change the internal representation of an object. • Separate the code of construction from the code of representation. • Control the construction process. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 39 of 51
  • 40. UML Diagrams And Design PatternsCreational Design Pattern (Contd.) • Builder Pattern (Contd.) • Object diagram depicting builder pattern: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 40 of 51
  • 41. UML Diagrams And Design PatternsCreational Design Pattern (Contd.) • Factory Method Pattern • Defines an interface to create an object but allows the subclasses to decide the class to be instantiated. • Helps construct individual objects for a specific purpose by deferring the instantiation to subclasses. • Enables addition of new classes without the need to modify the code, as the new class only needs to implement an interface. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 41 of 51
  • 42. UML Diagrams And Design PatternsCreational Design Pattern (Contd.) • Factory Method Pattern (Contd.) • Object diagram depicting factory method pattern: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 42 of 51
  • 43. UML Diagrams And Design PatternsCreational Design Pattern (Contd.) • Prototype Pattern • Provides a way to dynamically select the instantiation of an object and to return a clone of a prototypical object. • Is used when it is time-consuming to instantiate a highly complex class. • The advantages of using prototype pattern are: • Enables run-time addition or removal of objects. • Hides the concrete product classes from the client. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 43 of 51
  • 44. UML Diagrams And Design PatternsCreational Design Pattern (Contd.) • Prototype Pattern (Contd.) • Object diagram depicting prototype pattern: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 44 of 51
  • 45. UML Diagrams And Design PatternsCreational Design Pattern (Contd.) • Singleton Pattern • Ensures that a class has only a single instance and provides a global point of access to it. • Ensures all the objects that use the instance of the class use the same instance. • Is used when exactly a single instance of a class should exist. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 45 of 51
  • 46. UML Diagrams And Design PatternsCreational Design Pattern (Contd.) • Singleton Pattern (Contd.) • The advantages of using singleton pattern are: • Controls the access to the single instance of a class. • Lessens the use of namespaces. • Enables refinement of class operations and representation. • Allows variable number of class instances to exist. • Object diagram depicting singleton pattern: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 46 of 51
  • 47. UML Diagrams And Design PatternsIdentifying Creational Design Patterns • Problem Statement: • In the online product information system of Mastery Mechanics Engineering Inc., the product designer needs to brief the developer the kind of patterns that he/she can implement while developing the code so as to optimize the code. Identify the various creational patterns that can be applied to the above case study. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 47 of 51
  • 48. UML Diagrams And Design PatternsIdentifying Creational Design Patterns (Contd.) • Solution 1. Identify the Builder design pattern. 2. Identify the Factory Method design pattern. 3. Identify the Prototype pattern. 4. Identify the Singleton pattern. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 48 of 51
  • 49. UML Diagrams And Design PatternsSummaryIn this lesson, you learned: • The structure and design of an enterprise application can be represented by identifying the elements and analyzing the following nine UML diagrams: • Use case diagram: Depicts the various operations that a system performs. • Class diagram: Depicts the static design view of a system. It includes a set of classes and interfaces along with the collaborations and relationships among the classes and interfaces. • Package diagram: Depicts the grouping of related classes and interfaces of a given system. • Sequence diagram: Depicts the interaction between the objects of a system in the form of messages in a sequence by time. • Collaboration diagram: Depicts the interaction between objects of a system in the form of messages. • State diagram: Depicts how the object of a system reacts when an event occurs. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 49 of 51
  • 50. UML Diagrams And Design PatternsSummary (Contd.) • Activity diagram: Depicts the dynamic view of a system, showing the flow of control of the objects from one activity to another. • Component diagram: Depicts the grouping of packages and other components of a system, and their relationship with each other. • Deployment diagram: Depicts a deployment diagram that represents the configuration of the run-time processing nodes and the components that reside on the node. • Patterns are defined as proven solutions to problems in a given context. • The important elements of the GoF’s design patterns are pattern name, problem, solution, and consequences. • The advantages of using the design patterns in providing solutions to the real-world problems. • The GoF’s design patterns are categorized into three types, based on their purpose and scope: ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 50 of 51
  • 51. UML Diagrams And Design PatternsSummary (Contd.) • The GoF’s design patterns are categorized into three types, based on their purpose and scope: • Creational Design Patterns • Structural Design Patterns • Behavioral Design Patterns • The creational design patterns provide the techniques for creating objects. These patterns make a system independent of how the objects are created, composed, and represented. • The structural design patterns describe the composition and organization of the objects. • The behavioral design patterns provide the guidelines for enabling communication among various objects of a given system. • The various types of creational design patterns are abstract factory, builder, factory method, prototype, and singleton patterns. ©NIIT Architecting J2EE Solutions Lesson 2A / Slide 51 of 51