Jönköping University Object-Oriented Software Development Lecture 02 PDF

Document Details

ExcitedFresno5042

Uploaded by ExcitedFresno5042

Jönköping University, School of Engineering

2024

Johannes Schmidt

Tags

UML object-oriented programming software development Software Design

Summary

This document is a lecture on object-oriented software development, focusing on UML domain design. It details the use of UML and explains how to utilize different types of diagrams in software development.

Full Transcript

TOMK18/TOUK18 – 6/7.5 credits Autumn 2024 Object-Oriented Software Development / … with design patterns Lecture02 UML Domain Design Thursday August 29, 2024 Johannes Schmidt School of Engineering Agenda What is UML? Where to use it? Domain model + UML Class diagram Design model + UML Cl...

TOMK18/TOUK18 – 6/7.5 credits Autumn 2024 Object-Oriented Software Development / … with design patterns Lecture02 UML Domain Design Thursday August 29, 2024 Johannes Schmidt School of Engineering Agenda What is UML? Where to use it? Domain model + UML Class diagram Design model + UML Class diagram UML State machine diagram UML Interaction diagram, sequence, communication UML is just a tool, good design is something different What is UML? UML = Unified Modeling Language What is UML? A visual language for specifying, constructing and documenting the artifacts of systems. Visual: UML is a standardized diagramming notation. UML is not difficult to learn. Learning how to apply it skillfully might be more difficult. Where does UML come from? Object-oriented programming languages emerged in the 1960’s and 1970’s. The terms OO Analysis and OO Design came up later (1982) UML dates back to 1994, as an effort to standardize notation and to unify methods => UM = Unified Method. Unifying methods turned out to be too ambitious, so efforts were concentrated on just standardizing notation => UML = Unified Modeling Language Note: UML is thus not limited to an OO approach. Apply UML in three different ways UML as sketch. Sketching on whiteboard, to explore difficult parts of a problem, exploiting the power of visual languages. UML as blueprint. Relatively detailed design diagrams, used for either 1) reverse engineering existing code (to better understand it) 2) forward engineering (code generation) UML as programming language. Complete excecutable specifications of a software system in UML. What to use UML for? UML is a standardized diagramming notation. As such, it can be used to model nearly anything. Conceptual perspective: describe things of the real world. Specifications (software) perspective: describe software abstrations, components etc. without committing to a specific implementation (such as C#, Java). Implementation (software) perspective: concrete software implementation in a particular technology (C#, Java, …). Software Development Life Cycle (SDLC) requirements -> plan -> implement -> test/integrate -> operate Where should we use UML here, and for what? Use cases – and then? What to do with the use cases? Use cases capture requirements. And then? Start designing the system? Domain model Before designing the system it is in place to analyse a little more and to understand the situation better. Put on your Object-Oriented glasses, let’s start with OO analysis! A domain model, a.k.a. conceptual model, can help now: A representation of real-situation conceptual classes (not software classes!) Domain model Illustrates noteworthy concepts in a domain Can act as source of inspiration for designing system/objects Or is simply suitable to understand a situation or domain better Usually drawn in UML class diagram notation, keeping it simple (just attributes and associations, skip anything else) Domain model – how to create it 1. Find the conceptual classes 2. Draw them as classes in a UML class diagram 3. Add associations and attributes, not more Finding conceptual classes Three available methods. 1. Reuse or modify existing models 2. Use a category list 3. Identify noun phrases (e.g. in Use Cases) Using a category list It can help to scann in predefined categories from a certain perpective. E.g. from the perspective of business information needs: Coneptual Class Category Example Business transactions Sale, Payment, Reservation Transaction line items SalesLineItem Product or service related to a Item, Flight, Seat, Meal transaction or transaction line item Where is the transaction recorded Register, Ledger FlightManifest Roles of people or organisations Cashier, Customer, Store, Player, related to the transaction; actors in Passenger, Airline the use case Place of transaction; place of service Store, Airport, Plane, Seat … … Identify noun phrases Very simple method: linguistic analysis Indentify the nouns and noun phrases in textual descriptions of a domain. Those are candidates for conceptual classes or attributes. Textual descriptions: Use cases (fully dressed) Other (domain) documents In the minds of (domain) experts Identify noun phrases Domain model – how to create it 1. Find the conceptual classes 2. Draw them as classes in a UML class diagram 3. Add associations and attributes, not more Domain model – UML class diagram A class is represented by its name ClassName in a box. ClassName Attributes and methods can be added below the ClassName, Attributes separated by a line/box. Methods Domain model: only attributes Domain model – how to create it 1. Find the conceptual classes 2. Draw them as classes in a UML class diagram 3. Add associations and attributes, not more Associations An association is a relationship between classes (or instances of those classes) that indicates some meaningful and interesting connection. Associations – multiplicities Domain model – Associations Domain model – Attributes Domain model – Associations vs Attributes If a concept is usually a number or a text, make it an attribute. Otherwise, make it a conceptual class of its own. => Do not show complex concepts as attributes, but as associations Domain model – Description class A description class contains information that describes something else. E.g. ProductDescription records price, picture, text description of an Item Domain model – Description class Why use a description class? When use a description class? Domain model – Description class Use a description class when There needs to be a description about an item, independent of the current existence of such an item Deleting instances of things the description describes results in a loss of information that needs to be maintained It reduces redundant or duplicated information Domain model – more guidelines Do not get stuck on this step (analysis paralysis): Do not try to model a thorough, ”correct” domain model Invest not more than a few hours, then proceed Know that it will contain insufficiencies and that they will be fixed later A domain model is just meant to get you started and to get a good overview. It is particularly helpful if you are not familiar with the domain. What to use UML for? UML is a standardized diagramming notation. As such, it can be used to model nearly anything. Conceptual perspective: describe things of the real world. Specifications (software) perspective: describe software abstrations, components etc. without commiting to a specific implementation (such as C#, Java). Implementation (software) perspective: concrete software implementation in a particular technology (C#, Java, …). Design model The design model contains software classes and their relations. The design model is often inspired by the domain model, but it can well be very different. To draw a design model in UML is easy. To create a good design model is difficult. The more experience you have, the better you become in this discipline. Guidelines, principles, (design) patterns can be of help. Design model – more UML notation Domain, Use Case, Design diagram More UML More UML can be used in the analysis and design phases. E.g. state machine diagrams. Interaction diagrams Model how objects interact via messages. Two types of interaction diagrams in UML. 1. Sequence diagram 2. Communication diagram Sequence diagram 1. X-axis: list of actors / objects (from left to right) 2. Y-axis: timeline (from top to bottom) During a period of time (on the timeline), objects can be active/inactive, existing/non-existing, dead/alive … These different states are indicated by different line styles of the timeline (thick/thin, dottet, dashed etc.) Sequence Diagram Communication diagram Sequence vs Communication diagram Type Strengths Weaknesses Sequence Clearly shows sequence or Forced to extend to the right time ordering of messages, when adding new objects, large set of detailed notation consumes horizontal space options Communication Space economical, flexibility to More difficult to see sequence add new objects in two of messages, fewer notation dimensions options UML Is UML the silverbullet to software development? https://www.youtube.com/watch?v=hs9TYFsxkxE (focus on part 1 and 2, ignore part 3) Developing Software – basic idea Does not work well. Software Development requirements -> plan -> implement -> test/integrate -> operate Once a phase is completed, there is no way back Software Development requirements -> plan -> implement -> test/integrate -> operate Once a phase is completed, there is no way back => Waterfall model Software Development requirements -> plan -> implement -> test/integrate -> operate Software Development Life Cycle (SDLC) requirements -> plan -> implement -> test/integrate -> operate Developing Software – refined Iterative Incremental Agile Works much better. What is good design? Good design allows to fulfill the requirements, of course. In the context of iterative and incremental software development good design means being flexible, i.e., rendering future changes as easy as possible. Remember UML is just a tool. More important is to learn how to think in objects and what good design is. To create a good design model is difficult. The more experience you have, the better you become in this discipline. Guidelines, principles, (design) patterns can be of help. Recommended reading Applying UML and Patterns: ch. 9 Domain Models ch. 15 UML Interaction Diagrams ch. 16 UML Class Diagrams ch. 29 UML State Machine Diagrams UML reference https://www.uml-diagrams.org

Use Quizgecko on...
Browser
Browser