Full Transcript

This document is for private circulation only, For T. Y. Computer 2024-25 CCEW students. Subject: Software Design and Architecture PLEASE refer TO ALL REFERENCES plus Study Material CIRCULATED. Feel free to use additional web sites/searches for understanding if required. ACKNOWL...

This document is for private circulation only, For T. Y. Computer 2024-25 CCEW students. Subject: Software Design and Architecture PLEASE refer TO ALL REFERENCES plus Study Material CIRCULATED. Feel free to use additional web sites/searches for understanding if required. ACKNOWLEDGEMENT This presentation contains pictures, contents taken from multiple sources, authors and sites. We would like to appreciate and thank the authors, artists and do not claim any of following work to be ours, but it has been compiled here to use for academic purpose only. ACKNOWLEDGEMENT This presentation contains the contents taken exclusively from: Grady Booch, James Rumbaugh, Ivar Jacobson, 'The Unified Modeling Language User Guide', Pearson Education. We would like to appreciate and thank the above mentioned authors and do not claim any of following work to be ours, but it has been compiled here to use for academic purpose only. Class Diagram – Scope / Topics Class Diagram – Concepts, Notations, Examples - Classes: Attributes, methods, responsibilities - Entity, Boundary, Control classes - Relationships: Dependency, Association, Aggregation, Composition, Generalization - Objects, Encapsulation, Constructors, Messages, Polymorphism - Data hiding, Abstraction - Stereotypes, Tagged values, Constraints - Finding classes: Noun-Verb analysis, CRC cards - Modeling the vocabulary - Modeling the distribution of responsibilities - Modeling the structural relationships Class Diagram Ref: Grady Booch, James Rumbaugh, Ivar Jacobson, 'The Unified Modeling Language User Guide', Pearson Education, (2nd edition)(2008). Chapters: 4. Classes 5. Relationships 8. Class diagrams Chapter 10. Advanced Relationships Classes - Important Building Block of any Object-Oriented System Classes A class is a description of a set of objects that share the same attributes, operations, relationships and semantics. Classes are used to capture the vocabulary of the system. Classes are used to represent software, hardware and conceptual things. Classes A class is an abstraction of the things that are a part of your vocabulary. Classes Simple and Qualified Names Classes Attribute – A named property of a class that describes a range of values that instances of the property may hold. Classes Attributes Classes Operation – The implementation of a service that can be requested from any object of the class to affect behavior. Classes Operation and their Signatures – name, type, default value of all parameters Organizing Attributes and Operations Responsibilities A responsibility is a contract or an obligation of a class. Examples: – A Wall class is responsible for knowing about height, width and thickness. – A FraudAgent class, in a credit card application, is responsible for processing orders and determining if they are legitimate, suspect or fraudulent. – A TemperatureSensor class is responsible for measuring temperature and raising an alarm if the temperature reaches a certain point. Responsibilities What are objects? Objects consist of data and function packaged together in a reusable unit. Objects encapsulate data Every object is an instance of some class which defines the common set of features (attributes and operations) shared by all of its instances. Objects have: – Attribute values – the data part – Operations – the behaviour part All objects have: – Identity: Each object has its own unique identity and can be accessed by a unique handle – State: This is the actual data values stored in an object at any point in time – Behaviour: The set of operations that an object can perform Encapsulation operations attribute values Data is hidden inside the object. The only way to deposit() access the data is via one of the operations This is encapsulation or data withdraw() number = "1243" hiding and it is a very owner = "Jim Arlow" powerful idea. It leads to balance = 300.00 more robust software and getOwner() reusable code. setOwner() An Account Object Messaging In OO systems, objects send messages to each other over links These messages cause an object to invoke an operation Bank Object Account Object message withdraw( 150.00 ) the Bank object sends the the Account object responds by message “withdraw 150.00” to an invoking its withdraw operation. This Account object. operation decrements the account balance by 150.00. Object construction How do we create instances of classes? Each class defines one or more class scope operations which are constructors. These operations create new instances of the class BankAccount BankAccount +create( aNumber : int ) +BankAccount( aNumber : int ) generic constructor name Java/C++ standard Analysis - finding analysis classes Analyse a use case Business model [or domain model] Use case engineer Analysis class Requirements model Analyse a use case Use case model Use case realization Architecture description What are Analysis classes? Analysis classes represent a crisp abstraction in the problem domain BankAccount class name – They may ultimately be refined into one or more design name attributes address classes balance Analysis classes must map onto deposit() real-world business concepts operations withdraw() calculateInterest() Analysis Class to Design Class Source: Internet Design phase may add Address class Finding classes Perform noun/verb analysis on documents: – Nouns are candidate classes- ex flight – Verbs are candidate responsibilities – ex allocate Perform CRC card analysis – A brainstorming technique using sticky notes – Useful for brainstorming, Joint Application Development (JAD) and Rapid Application development (RAD) Noun Identification: A Library Example The library contains books and journals. It may have several copies of a given book. Some of the books are reserved for short-term loans only. All others may be borrowed by any library member for three weeks. Members of the library can normally borrow up to six items at a time, but members of staff may borrow up to 12 items at one time. Only members of staff may borrow journals. The system must keep track of when books and journals are borrowed and returned and enforce the rules. Relations between Classes Book is an Item Journal is an Item Copy is a copy of a Book LibraryMember Item MemberOfStaff is a LibraryMember Is Item needed? Operations LibraryMember borrows Copy LibraryMember returns Copy MemberOfStaff borrows Journal MemberOfStaff returns Journal Item not needed yet. Class Diagram MemberOfStaff LibraryMember 1 1 on loan on loan 0..* 0..12 Journal Copy is a copy of Book 1..* 1 CRC card procedure Class Name: BankAccount Responsibilities: Collaborators: things the Maintain balance Bank things the class does class works with Class, Responsibilities and Collaborators Separate information collection from information analysis – Part 1: Brainstorm All ideas are good ideas in CRC analysis Never argue about something – write it down and analyse it later! – Part 2: Analyse information - consolidate with noun/verb Source: Internet Source: Internet Case example: Finding Classes Suggested Classes  Library, Librarian, User, Borrower, Article, Material, Item, Due Date, Fine, Book, Video, and Journal Classes after filtering  Librarian, Book, Video, Journal, Date, Borrower and User Assigning Cards  A CRC Card per Class, put name & description of the class Class Diagram DigitizedMap WeatherStation WeatherMap location location metereologicalData date-time 1 collectData() 1...* geographicData getSummary() weather summary gatherData() printMap() Finding Classes Stereotype Semantics A class that mediates interaction between the system and its environment A class that encapsulates use-case specific behavior A class that is used to model persistent information about something. Example: class generalization more general element parent superclass Shape base class generalisation ancestor “is kind of” specialisation Square Circle Triangle child subclass more specific elements descendent A generalisation hierarchy BankAccount example BankAccount 1 * withdraw() Bank calculateInterest() deposit() ShareAccount CheckingAccount DepositAccount withdraw() withdraw() withdraw() calculateInterest() calculateInterest() calculateInterest() deposit() We have overridden the deposit() operation even though it is not abstract. This is perfectly legal, and quite common, although it is generally considered to be bad style and should be avoided if possible Modeling the Vocabulary of a System Example: A retail system Modeling the Distribution of Responsibilities in a System No one class does too much or too little Modeling Non-software Things Modeling Primitive Types Relationships - Things do not stand alone, but in relation to one another Relationships A relationship is a connection among things - Dependencies - Generalizations - Associations Dependencies A dependency is a using relationship that states that a change in specification of one thing (for example, class Event) may affect another thing that uses it (for example, class Window), but not necessarily the reverse. Dependencies are used in the context of classes to show that one class uses another class as an argument in the signature of an operation. Dependencies If the used class changes, the operation of the other class may be affected, as well, because the used class may now present a different interface or behavior. Generalizations Associations An association is a structural relationship that specifies that objects of one thing are connected to objects of another. Examples: – Rooms consist of walls and other things; walls themselves may have embedded doors and windows; pipes may pass through walls. An association that connects exactly two classes is called a binary association. Associations that connect more than two classes are called n-ary associations. Association Names Association End Names (Role Names) Association - Multiplicity Aggregation A whole / part relationship “has-a” relationship Modeling Simple Dependencies Modeling Single Inheritance Modeling Structural Relationships Class Diagrams Class Diagram Class Diagrams Static Design View of a System – Model the vocabulary of a system – Model simple collaborations – Model a logical database schema Modeling Simple Collaborations A collaboration is a society of classes, interfaces, and other elements that work together to provide some cooperative behavior that's bigger than the sum of all the elements. Modeling Simple Collaborations Example: the classes involved in the mechanism for moving the robot along a path. Modeling a Logical Database Schema A schema as the blueprint for the conceptual design of a database. In many domains, its needed to store persistent information in a relational database or in an object- oriented database. You can model schemas for these databases using class diagrams. Modeling a Logical Database Schema SRS - Example of external interfaces Source: Internet ACKNOWLEDGEMENT This presentation contains the contents taken exclusively from: Grady Booch, James Rumbaugh, Ivar Jacobson, 'The Unified Modeling Language User Guide', Pearson Education. We would like to appreciate and thank the above mentioned authors and do not claim any of following work to be ours, but it has been compiled here to use for academic purpose only. ACKNOWLEDGEMENT This presentation contains pictures, contents taken from multiple sources, authors and sites. We would like to appreciate and thank the authors, artists and do not claim any of above work to be ours, but it has been compiled here to use for academic purpose only.

Use Quizgecko on...
Browser
Browser