Week 13 Object-Oriented Analysis and Design Using UML PDF

Summary

This document covers object-oriented analysis and design using UML. It details the different UML diagrams, their uses, and functions. It also discusses object-oriented development life cycle, including phases like requirements gathering, system design, and implementation.

Full Transcript

INSY 55: System Analysis and Design Week 13: Object-Oriented Analysis and Design Using UML After the completion of the chapter, students should be able to: 1.list the different UML diagrams; 2.identify the uses and functions of each UML diagrams; and 3.identify the various symb...

INSY 55: System Analysis and Design Week 13: Object-Oriented Analysis and Design Using UML After the completion of the chapter, students should be able to: 1.list the different UML diagrams; 2.identify the uses and functions of each UML diagrams; and 3.identify the various symbols or conventions used in each UML diagrams. XII. Object-Oriented Analysis and Design Using UML 12.1 Object-Oriented Development Life Cycle The Object-Oriented Development Life Cycle (OODLC) is a structured approach to software development that emphasizes the use of object-oriented principles and methodologies. This life cycle is designed to improve the quality of software systems by focusing on the design and implementation of objects, which encapsulate both data and behavior. Below are the key phases of the OODLC: 1. Requirements Gathering and Analysis Objective: Understand the needs of stakeholders and define the system requirements. Activities: o Conduct interviews, surveys, and workshops with users and stakeholders. o Document functional and non-functional requirements. o Identify use cases that describe how users will interact with the system. 2. System Design Objective: Create a blueprint for the system architecture and design. Activities: o Define the overall system architecture, including components and their interactions. o Identify and design classes, objects, and their relationships (e.g., inheritance, composition). o Create design models using Unified Modeling Language (UML) diagrams, such as class diagrams, sequence diagrams, and use case diagrams. 3. Implementation (Coding) Objective: Translate design specifications into executable code. Activities: o Write code for classes and methods based on the design models. o Implement data structures and algorithms as needed. o Conduct unit testing to ensure individual components function correctly. 4. Testing Objective: Validate that the system meets the specified requirements and is free of defects. Activities: o Perform integration testing to ensure that different components work together as intended. o Conduct system testing to evaluate the overall functionality and performance of the system. o Execute user acceptance testing (UAT) to confirm that the system meets user expectations. 5. Deployment Objective: Release the system to users and ensure it operates in the production environment. Activities: o Prepare deployment plans, including installation procedures and user training. o Deploy the system to the production environment. o Monitor the system for any issues post-deployment and provide support as needed. 6. Maintenance and Evolution Objective: Address issues, implement enhancements, and adapt the system to changing requirements. Activities: o Fix bugs and performance issues identified by users. o Implement new features and enhancements based on user feedback and changing business needs. o Conduct regular reviews and updates to ensure the system remains relevant and effective. 12.2 Object-Oriented Concepts Object-oriented programming (OOP) is a programming paradigm that uses "objects" to represent data and methods to manipulate that data. The core concepts of OOP provide a framework for designing and implementing software systems in a way that promotes reusability, scalability, and maintainability. Below are the fundamental concepts of object-oriented development: 1. Classes and Objects Class: A blueprint or template for creating objects. It defines the properties (attributes) and behaviors (methods) that the objects created from the class will have. Object: An instance of a class. It encapsulates data and functionality, allowing for interaction with the data through its methods. 2. Encapsulation Definition: The bundling of data (attributes) and methods (functions) that operate on the data into a single unit, or class. Encapsulation restricts direct access to some of the object's components, which is a means of preventing unintended interference and misuse of the methods and data. Benefits: o Protects the internal state of an object. o Promotes modularity and separation of concerns. o Facilitates maintenance and updates. 3. Inheritance Definition: A mechanism that allows one class (the subclass or derived class) to inherit attributes and methods from another class (the superclass or base class). This promotes code reusability and establishes a hierarchical relationship between classes. Benefits: o Reduces code duplication by allowing subclasses to reuse code from superclasses. o Enables polymorphism, where a subclass can override methods of its superclass. 4. Polymorphism Definition: The ability of different classes to be treated as instances of the same class through a common interface. Polymorphism allows methods to be defined in a way that they can operate on objects of different classes. Types: o Compile-time Polymorphism: Achieved through method overloading (same method name with different parameters). o Run-time Polymorphism: Achieved through method overriding (subclass provides a specific implementation of a method already defined in its superclass). 5. Abstraction Definition: The concept of hiding the complex implementation details of a system and exposing only the necessary and relevant parts to the user. Abstraction allows users to interact with objects at a high level without needing to understand the underlying complexity. Benefits: o Simplifies the interface for users. o Reduces complexity and increases efficiency in software development. 6. Message Passing Definition: The process by which objects communicate with one another by sending and receiving messages (method calls). This is a fundamental aspect of object- oriented design, as it allows for interaction between objects. Benefits: o Promotes loose coupling between objects, making the system more flexible and easier to maintain. 12.3 The Unified Modeling Language The Unified Modeling Language (UML) is a standardized modeling language used in software engineering to specify, visualize, develop, and document the artifacts of software systems. UML provides a set of graphic notation techniques to create visual models of object-oriented systems, facilitating communication among stakeholders and aiding in the design and analysis of software applications. Key Features of UML 1. Standardization: UML is an industry-standard language that provides a common framework for modeling software systems, ensuring consistency and clarity in documentation. 2. Visual Representation: UML uses diagrams to represent various aspects of a system, making it easier to understand complex systems through visual means. 3. Support for Object-Oriented Design: UML is specifically designed to support object-oriented methodologies, making it suitable for modeling systems that use OOP principles. 4. Flexibility: UML can be used for a wide range of applications, from high-level system architecture to detailed design specifications. Types of UML Diagrams UML includes several types of diagrams, which can be categorized into two main groups: Structural Diagrams and Behavioral Diagrams. 1. Structural Diagrams These diagrams represent the static aspects of a system, focusing on the organization and structure of the system's components. Class Diagram: Shows the classes in a system, their attributes, methods, and relationships (associations, inheritance, etc.). Component Diagram: Illustrates the components of a system and their dependencies, focusing on the physical aspects of the system. Deployment Diagram: Represents the physical deployment of artifacts on nodes, showing how software components are distributed across hardware. Object Diagram: Displays instances of classes (objects) and their relationships at a specific point in time. 2. Behavioral Diagrams These diagrams represent the dynamic aspects of a system, focusing on how the system behaves and interacts over time. Use Case Diagram: Captures the functional requirements of a system by showing the interactions between users (actors) and the system's use cases. Sequence Diagram: Illustrates how objects interact in a particular scenario of a use case, showing the sequence of messages exchanged. Activity Diagram: Represents the flow of control or data in a system, showing the sequence of activities and decisions. State Diagram: Describes the states of an object and the transitions between those states in response to events. 12.4 Use Case Modeling Use case modeling is a technique used in software and systems engineering to identify and clarify the functional requirements of a system. It focuses on the interactions between users (actors) and the system to achieve specific goals. Use case modeling is an essential part of the requirements gathering and analysis phase of the software development life cycle (SDLC). Key Components of Use Case Modeling 1. Actors: o An actor represents a user or another system that interacts with the system being developed. Actors can be primary (those who initiate the interaction) or secondary (those who provide a service or support the primary actor). o Examples of actors include end-users, administrators, external systems, and devices. 2. Use Cases: o A use case is a description of a specific interaction between an actor and the system that results in a measurable outcome. It outlines the steps taken by the actor to achieve a goal and the system's responses. o Each use case should have a clear name, a defined scope, and a set of preconditions and postconditions. 3. Relationships: o Use cases can have relationships with other use cases, which include: ▪ Include: Indicates that a use case contains the behavior of another use case. This is used for shared functionality. ▪ Extend: Indicates that a use case can be extended by another use case, adding optional behavior under certain conditions. ▪ Generalization: Represents a hierarchy where a more specific use case inherits behavior from a more general use case. Steps in Use Case Modeling 1. Identify Actors: Determine who will interact with the system and define their roles. This includes both primary and secondary actors. 2. Identify Use Cases: For each actor, identify the goals they want to achieve with the system. Each goal corresponds to a use case. 3. Define Use Case Scenarios: For each use case, describe the main flow of events (the normal course) and any alternative flows (exceptional or error conditions). This includes: o Preconditions: Conditions that must be true before the use case can start. o Main Success Scenario: The sequence of steps that lead to a successful outcome. o Alternative Flows: Variations in the main flow that may occur due to different conditions or errors. o Postconditions: Conditions that will be true after the use case has been completed. 4. Create Use Case Diagrams: Visualize the relationships between actors and use cases using UML use case diagrams. This provides a high-level overview of the system's functionality. 12.5 Creating Use Case Diagrams Use case diagrams are a visual representation of the interactions between actors and the system, illustrating the system's functional requirements. They are part of the Unified Modeling Language (UML) and serve as a high-level overview of the system's capabilities. Creating use case diagrams involves several steps and best practices to ensure clarity and effectiveness. Key Elements of Use Case Diagrams 1. Actors: o Represented by stick figures, actors are external entities that interact with the system. They can be users, other systems, or devices. o Each actor should be labeled with a descriptive name that indicates their role. 2. Use Cases: o Represented by ovals, use cases describe specific functionalities or services provided by the system. o Each use case should have a clear and concise name that reflects the goal of the interaction. 3. System Boundary: o Represented by a rectangle, the system boundary defines the scope of the system being modeled. Use cases are placed inside this rectangle, while actors are placed outside. o The boundary helps to distinguish between what is part of the system and what is external. 4. Relationships: o Lines connect actors to use cases, indicating interactions. These relationships can include: ▪ Association: A simple line connecting an actor to a use case, showing that the actor participates in the use case. ▪ Include: A dashed arrow pointing from one use case to another, indicating that the included use case is a part of the base use case. ▪ Extend: A dashed arrow pointing from an extending use case to a base use case, indicating optional behavior that can occur under certain conditions. ▪ Generalization: A line with a hollow triangle pointing from a specialized actor or use case to a more general one, indicating inheritance. Steps to Create Use Case Diagrams 1. Identify Actors: o Determine all the external entities that will interact with the system. This includes users, other systems, and devices. 2. Identify Use Cases: o For each actor, identify the goals they want to achieve with the system. Each goal corresponds to a use case. 3. Define Relationships: o Establish the relationships between actors and use cases, as well as any include or extend relationships between use cases. 4. Draw the Diagram: o Start by drawing the system boundary as a rectangle. o Place the identified use cases inside the rectangle and label them appropriately. o Position the actors outside the rectangle and connect them to the relevant use cases using lines to represent associations. o Add any include or extend relationships as dashed arrows. 5. Review and Refine: o Review the diagram with stakeholders to ensure accuracy and completeness. Make adjustments as necessary to improve clarity and understanding. 12.6 Creating Use Case Scenarios Use case scenarios provide a detailed narrative of how users interact with a system to achieve specific goals. They complement use case diagrams by offering a more in-depth understanding of the functional requirements and user interactions. Creating use case scenarios involves outlining the steps taken by actors in various situations, including normal and exceptional paths. Key Components of Use Case Scenarios 1. Use Case Name: o A clear and descriptive title that identifies the use case. 2. Actors: o The primary and secondary actors involved in the scenario. Primary actors initiate the use case, while secondary actors support the process. 3. Preconditions: o Conditions that must be true before the use case can be initiated. These set the stage for the scenario. 4. Postconditions: o The state of the system after the use case has been completed. This includes any changes made to the system or data. 5. Main Success Scenario (Normal Course): o A step-by-step description of the interactions between the actor and the system that lead to a successful outcome. This outlines the primary path through the use case. 6. Extensions (Alternative Paths): o Descriptions of alternative scenarios that may occur, including error handling and exceptional cases. These provide insight into how the system should respond to various situations. Steps to Create Use Case Scenarios 1. Identify the Use Case: o Start with a specific use case that you want to develop a scenario for. Ensure that it is well-defined and understood. 2. Define Actors: o Identify the primary and secondary actors involved in the use case. Understand their roles and interactions with the system. 3. Establish Preconditions: o List the conditions that must be met before the use case can begin. This may include user authentication, data availability, or system readiness. 4. Outline Postconditions: o Describe the expected outcomes after the use case is executed. This includes any changes to the system state or data. 5. Detail the Main Success Scenario: o Write a narrative that outlines the step-by-step interactions between the actor and the system. Use clear and concise language to describe each action and response. 6. Identify Extensions: o Consider alternative paths that may occur during the use case. Describe how the system should handle errors, exceptions, or variations in the process. 7. Review and Refine: o Share the use case scenario with stakeholders for feedback. Make adjustments based on their input to ensure accuracy and completeness. 12.7 Activity Diagrams Activity diagrams are a type of behavioral diagram in Unified Modeling Language (UML) that represent the flow of control or data within a system. They are particularly useful for modeling the dynamic aspects of a system, illustrating the sequence of activities and the conditions that govern the flow from one activity to another. Activity diagrams can be used to visualize the workflow of a use case, making them an effective tool for understanding complex processes. Key Components of Activity Diagrams 1. Activities: o Represented by rounded rectangles, activities are the tasks or actions that are performed in the process. 2. Transitions: o Arrows that connect activities, indicating the flow of control from one activity to another. Transitions can be labeled with conditions that must be met for the flow to continue. 3. Start Node: o A filled black circle that indicates the beginning of the activity flow. 4. End Node: o A filled black circle surrounded by a hollow circle, representing the completion of the activity flow. 5. Decision Nodes: o Diamonds that represent points in the flow where a decision must be made, leading to different paths based on the outcome of the decision. 6. Forks and Joins: o Forks (horizontal or vertical bars) split a flow into multiple concurrent flows, while joins combine multiple flows back into a single flow. 7. Swimlanes: o Vertical or horizontal divisions that group activities by actor or role, clarifying who is responsible for each part of the process. Steps to Create Activity Diagrams 1. Identify the Process: o Determine the specific process or workflow that you want to model. This could be a use case or a broader business process. 2. Define Activities: o List all the activities involved in the process. Ensure that each activity is clearly defined and represents a distinct task. 3. Establish the Flow: o Determine the sequence of activities and how they are connected. Identify any decision points that may affect the flow. 4. Add Decision Nodes: o Incorporate decision nodes where applicable, indicating the conditions that lead to different paths in the flow. 5. Include Forks and Joins: o If the process involves concurrent activities, use forks to split the flow and joins to combine it back. 6. Organize with Swimlanes: o If multiple actors are involved, use swimlanes to clearly delineate responsibilities and interactions. 7. Review and Refine: o Share the activity diagram with stakeholders for feedback. Make adjustments to ensure clarity and accuracy. 12.8 Sequence Diagrams Sequence diagrams are a type of interaction diagram in Unified Modeling Language (UML) that illustrate how objects interact in a particular scenario of a use case. They show the sequence of messages exchanged between objects over time, providing a clear view of the dynamic behavior of a system. Sequence diagrams are particularly useful for detailing the interactions in a system and understanding the order of operations. Key Components of Sequence Diagrams 1. Lifelines: o Represented by vertical dashed lines, lifelines indicate the presence of an object or participant in the interaction. Each lifeline is labeled with the name of the object. 2. Activation Boxes: o Rectangles placed on lifelines that indicate the period during which an object is active or controlling the flow of the interaction. 3. Messages: o Horizontal arrows between lifelines that represent the communication between objects. Messages can be synchronous (solid line with a filled arrowhead) or asynchronous (solid line with an open arrowhead). 4. Return Messages: o Dashed arrows that indicate the return of control or data from one object to another after a message has been sent. 5. Combined Fragments: o Sections of the diagram that represent control structures, such as loops, alternatives, or parallel processes. These are enclosed in a rectangle with a label indicating the type of fragment. 6. Notes: o Annotations that provide additional information about the diagram. Notes are represented by a rectangle with a folded corner. Steps to Create Sequence Diagrams 1. Identify the Scenario: o Determine the specific scenario or use case that you want to model. This should be a clear interaction between objects. 2. List the Objects: o Identify the objects or participants involved in the interaction. Each object will have its own lifeline in the diagram. 3. Define the Messages: o Outline the messages exchanged between the objects. Specify the order of messages and whether they are synchronous or asynchronous. 4. Add Activation Boxes: o Indicate when each object is active during the interaction by placing activation boxes on the corresponding lifelines. 5. Include Return Messages: o Add return messages to show the flow of control back to the calling object after a message has been processed. 6. Incorporate Combined Fragments: o If the interaction involves control structures (like loops or alternatives), use combined fragments to represent these elements. 7. Review and Refine: o Share the sequence diagram with stakeholders for feedback. Make necessary adjustments to ensure clarity and accuracy. 12.9 Collaboration Diagrams Collaboration diagrams, also known as communication diagrams, are a type of interaction diagram in Unified Modeling Language (UML) that emphasize the structural organization of the objects that interact in a particular scenario. Unlike sequence diagrams, which focus on the time sequence of messages, collaboration diagrams illustrate how objects are connected and how they communicate with each other to achieve a specific goal. Key Components of Collaboration Diagrams 1. Objects: o Represented by rectangles, objects are the participants in the interaction. Each object is labeled with its name and class. 2. Links: o Lines connecting the objects that represent the relationships or associations between them. Links indicate that the objects can communicate with each other. 3. Messages: o Labeled arrows along the links that indicate the messages exchanged between objects. Each message is numbered to show the order of communication. 4. Sequence Numbers: o Messages are numbered to indicate the sequence in which they are sent. This helps clarify the flow of communication among the objects. 5. Notes: o Annotations that provide additional information about the diagram. Notes are represented by a rectangle with a folded corner. Steps to Create Collaboration Diagrams 1. Identify the Scenario: o Determine the specific scenario or use case that you want to model. This should involve a clear interaction among multiple objects. 2. List the Objects: o Identify the objects or participants involved in the interaction. Each object will be represented in the diagram. 3. Define the Links: o Establish the relationships between the objects by drawing links that connect them. 4. Outline the Messages: o Specify the messages exchanged between the objects. Number the messages to indicate the order of communication. 5. Add Notes: o Include any necessary annotations to clarify the diagram or provide additional context. 6. Review and Refine: o Share the collaboration diagram with stakeholders for feedback. Make adjustments to ensure clarity and accuracy. 12.10 Class Diagrams Class diagrams are a fundamental part of Unified Modeling Language (UML) and are used to represent the static structure of a system. They illustrate the system's classes, their attributes, methods, and the relationships between the classes. Class diagrams are essential for object-oriented design and serve as a blueprint for the implementation of the system. Key Components of Class Diagrams 1. Classes: o Represented as rectangles divided into three sections: the top section contains the class name, the middle section contains attributes, and the bottom section contains methods (operations). o Example: 2. Attributes: o Characteristics or properties of a class. They are typically listed with their visibility (public, private, protected), name, and type. o Example: - customerID: int indicates a private attribute customerID of type integer. 3. Methods (Operations): o Functions or behaviors that a class can perform. They are also listed with their visibility, name, and parameters. o Example: + placeOrder() indicates a public method placeOrder with no parameters. 4. Relationships: o Association: A basic relationship where one class is connected to another. It can be unidirectional or bidirectional. ▪ Example: A Customer can have an association with an Order. o Aggregation: A special form of association that represents a "whole-part" relationship. It is depicted with a hollow diamond at the whole end. ▪ Example: A Library can aggregate Books. o Composition: A stronger form of aggregation where the part cannot exist without the whole. It is depicted with a filled diamond at the whole end. ▪ Example: A House is composed of Rooms. o Inheritance: Represents a "is-a" relationship where one class (subclass) inherits from another class (superclass). It is depicted with a solid line and a closed arrow pointing to the superclass. ▪ Example: Employee is a subclass of Person. Example of a Class Diagram Here’s a simple example of a class diagram for an online shopping system: Use Cases for Class Diagrams System Design: Class diagrams are used during the design phase to define the structure of the system and how different classes interact. Documentation: They serve as documentation for the system, providing a clear overview of the classes and their relationships. Code Generation: Class diagrams can be used as a basis for generating code in object- oriented programming languages. 12.11 Generalization/ Specialization Diagrams Generalization Definition: Generalization is the process of extracting shared characteristics from two or more classes (entities) and combining them into a generalized superclass. This is useful when multiple entities share common attributes or relationships. Example: Consider a scenario where you have two entities: Car and Truck. Both share common attributes like Make, Model, and Year. You can create a generalized entity called Vehicle that encompasses these shared attributes. Diagram Representation: In an ERD, generalization is typically represented by a triangle pointing towards the superclass (generalized entity) and lines connecting the subclasses (specialized entities) to the superclass. Specialization Definition: Specialization is the process of creating new subclasses from an existing class (entity) based on some distinguishing characteristics. This allows for more specific attributes or relationships to be defined for the subclasses. Example: Continuing with the previous example, if you have a Vehicle entity, you can specialize it into Car, Truck, and Motorcycle, each with its own specific attributes. For instance, Car might have an attribute NumberOfDoors, while Truck might have PayloadCapacity. Diagram Representation: In an ERD, specialization is represented similarly to generalization, with the superclass at the top and lines connecting to the specialized subclasses below. Key Points 1. Hierarchical Structure: Both generalization and specialization create a hierarchical structure that helps in organizing data logically. 2. Inheritance: Subclasses inherit attributes and relationships from their superclass, which promotes reusability and reduces redundancy. 3. Use Cases: These concepts are particularly useful in scenarios where entities share common features but also have unique characteristics that need to be captured. 12.12 Statechart Diagrams Statechart diagrams, also known as state machine diagrams, are a type of behavioral diagram in Unified Modeling Language (UML) that represent the states of an object and the transitions between those states. They are particularly useful for modeling the dynamic behavior of a system, especially for objects that undergo various states in response to events. Key Components of Statechart Diagrams 1. States: o Represent the various conditions or situations in which an object can exist. States are typically depicted as rounded rectangles. o Example: An order can be in states such as "Pending," "Shipped," "Delivered," or "Cancelled." 2. Transitions: o Arrows that connect states, indicating the movement from one state to another. Transitions are triggered by events or conditions. o Example: An order transitions from "Pending" to "Shipped" when the shipping process is initiated. 3. Events: o Triggers that cause a transition to occur. Events can be user actions, system events, or messages from other objects. o Example: An event could be "Ship Order" that triggers the transition from "Pending" to "Shipped." 4. Initial State: o Represented by a filled black circle, indicating where the state machine begins. o Example: The initial state of an order could be "Pending." 5. Final State: o Represented by a circle with a dot inside, indicating the completion of the state machine's behavior. o Example: The final state could be "Delivered." 6. Actions: o Activities that occur as a result of a transition. Actions can be specified on transitions or states. o Example: An action could be "Notify Customer" when the order is shipped. Example of a Statechart Diagram Here’s a simple example of a statechart diagram for an online order process: Use Cases for Statechart Diagrams Modeling Complex Behaviors: Statechart diagrams are particularly useful for modeling the behavior of complex systems where objects can be in multiple states and respond to various events. Real-Time Systems: They are often used in real-time systems where the timing of events is critical. User Interfaces: Statecharts can model the states of user interface components, such as buttons or forms, based on user interactions.

Use Quizgecko on...
Browser
Browser