1 / 29

MCS 270 Spring 2014

MCS 270 Spring 2014. Object-Oriented Software Development. MCS 270 Object-Oriented Software Development. Today ’ s schedule. Basics of UML Class Diagrams. MCS 270 Object-Oriented Software Development. Unified modeling language (UML).

Download Presentation

MCS 270 Spring 2014

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. MCS 270 Spring 2014 Object-Oriented Software Development

  2. MCS 270 Object-Oriented Software Development Today’s schedule Basics of UML Class Diagrams

  3. MCS 270 Object-Oriented Software Development Unified modeling language (UML) 1980’s and 90’s - Several competing object-oriented notations (Babel of notation) 1994 - Rumbaugh (one of our textbook’s authors) and Booch began working at IBM Rational to standardize their notations (OMT and Booch) Result was Unified Modeling Language (UML) Rights owned by Object Management Group (OMG), www.omg.org

  4. MCS 270 Object-Oriented Software Development Unified modeling language (UML) • Collection of notations representing software designs from three points of view: • Class model • State model • Interaction model • Generally need all three models to describe a system • No single model describes everything in problem domain

  5. MCS 270 Object-Oriented Software Development Unified modeling language (UML) • Class model: describes the static structure of objects and relationships in a system • Comprises object and class diagrams • State model:describes the dynamic aspects of objects and the nature of control in a system • Interaction model: describes how objects in a system cooperate to achieve broader results

  6. MCS 270 Object-Oriented Software Development Class Model

  7. MCS 270 Object-Oriented Software Development Good Class/Object Design Meaningful concept or “thing” in an application domain Has identity that does not encapsulate an object within itself, does not use attribute values of another object Classes model relationships among things in domain

  8. MCS 270 Object-Oriented Software Development Good Class/Object Design City What is wrong with this definition of a city class? cityName : String population : int timeZone : String airportName : String airportCode : String

  9. MCS 270 Object-Oriented Software Development Good Class/Object Design City What is wrong with this definition of a city class? cityName : String population : int timeZone : String airportName : String airportCode : String Answer: These attributes “hide” an object (i.e., an airport) that is meaningful in this domain

  10. MCS 270 Object-Oriented Software Development Question • Why might it be bad to encode one object as a collection of attribute values within another?

  11. MCS 270 Object-Oriented Software Development Question • Why might it be bad to encode one object as a collection of attribute values within another? • Potential for redundancy/inconsistency • some airports serve multiple cities • some cities served by no airports • some cities served by multiple airports • Operations over Airport objects may not need to know details associated with cities, such as population

  12. MCS 270 Object-Oriented Software Development Design tip • When designing a class: • Apply the identity test to each attribute (does attribute belong to class?) • Never use an attribute to model another object attribute • UML notation helps enforce this discipline • Next: how do we model connections between objects, such as Cities and Airports?

  13. MCS 270 Object-Oriented Software Development Relationships among objects • Link: Physical or conceptual connection between objects • Most (not all) links relate exactly two objects • Association: Description of a group of links with common structure and semantics • A link is an instance of an association: • Links connect objects • Association describes set of potential links just as a class describes a set of potential objects

  14. Houston : City HOU : Airport IAH : Airport cityName = “Houston, TX” population = 3000000 airportCode = “HOU” airportName = “Hobby” timeZone = “Central” airportCode = “IAH” airportName = “Intercontinental” timeZone = “Central” MCS 270 Object-Oriented Software Development Examples of links Serves Serves

  15. City Airport cityName : String population : int airportName : String airportCode : String timeZone : String MCS 270 Object-Oriented Software Development Example of an association multiplicities 1..* * Serves association name

  16. Professor University MCS 270 Object-Oriented Software Development Association End Names Association end name defines role of Object  The class could play same or different roles in other associations. Ex: Professor could also be classified as Teacher Association Name WorksFor Employee Employer End Names

  17. Parent Child Person MCS 270 Object-Oriented Software Development Association End Names Association end name is used for multiple references to same class  parent 0..2 2 * * child Not advisable – only use one class to represent a person Better

  18. MCS 270 Object-Oriented Software Development New abstraction: Generalization (Sub-Super) • This is the “is-a”relation • Relates class to one that is “more general” • Open arrow points to Base Class • Derived class inherits all attributes/operations of parent • Relation is anti-symmetric and transitive Employee first_name : String last_name : String hire_date : Date department : int * group Manager level : short 0..1

  19. MCS 270 Object-Oriented Software Development Cheat Sheet • Book – front and back have summary of diagrams • Handout – another summary with annotated explanations

  20. MCS 270 Object-Oriented Software Development Practice

  21. MCS 270 Object-Oriented Software Development Practice

  22. MCS 270 Object-Oriented Software Development Practice • Groups of two: Create a class model to describe undirected graphs. An undirected graph consists of edges connecting pairs of vertices. An undirected graph with 6 nodes and 7 edgesen.wikipedia.org/wiki/Graph_(mathematics)

  23. MCS 270 Object-Oriented Software Development Practice • Groups of two: Create a class model to describe directed graphs. Here edges are directed from start to end. A directed graph with 3 nodes and 3 edgesen.wikipedia.org/wiki/Graph_(mathematics)

  24. MCS 270 Object-Oriented Software Development Why do we use UML? • A Picture = Rich Data Encoding: we think in pictures and can relate info quickly in figures • Creative destruction: Diagrams are easily changed, programs not so much • Employment: UML is used in the workplace

  25. MCS 270 Object-Oriented Software Development Design tips • Use a UML diagram when: • Brainstorming ideas • Sharing ideas with team • Saving blueprint of idea • You can't find a bug in code • Teacher/manager requires it

  26. MCS 270 Object-Oriented Software Development Design tips • Keep it simple – only use UML when you need to • Manage Complexity: Draw diagrams that give most value, e.g. do not draw a diagram for system with one or two classes. Likewise, do not put in all detail in first iteration.

  27. MCS 270 Object-Oriented Software Development Design tips • Good design practice: switch back and forth between what is said in the diagram and what is allowable in the code • Good Programming Practice: Plan code using links/associations rather than Java classes and methods. • This is good training in abstraction!

  28. MCS 270 Object-Oriented Software Development Summary • UML provides notations for modeling objects, classes, and • associations of an application domain • Diagrams represent models: • more abstract than code • useful for explanation/documentation

  29. MCS 270 Object-Oriented Software Development Assignments Friday - Read Chapter 5 in text. Homework: Chapter 3. Exercises 3.8, 3.11, and 3.12 Due Monday, Feb. 17

More Related