1 / 12

Object Diagrams

Object Diagrams. Address. Customer. Street: String city: String state: String zipCode: int. firstName: String Lastname: String id: int. Class diagram. getAddress(): Address. getCity(): String. :Customer. :Address. johnSmith :Customer. homeAddr : Address. Object diagram.

ralph
Télécharger la présentation

Object Diagrams

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. Object Diagrams Address Customer Street: String city: String state: String zipCode: int firstName: String Lastname: String id: int Class diagram getAddress(): Address getCity(): String :Customer :Address johnSmith :Customer homeAddr : Address Object diagram homeAddr :Address JohnSmith :Customer Street: String city: String state: String zipCode: int firstName: String Lastname: String id: int getAddress(): Address getCity(): String

  2. Customer Address firstName: String Lastname: String id: int Street: String city: String state: String zipCode: int 1 Class diagram - homeAddr getAddress(): Address getCity(): String homeAddr : Address johnSmith :Customer Object diagram

  3. Customer Address firstName: String Lastname: String id: int Street: String city: String state: String zipCode: int 1..2 Class diagram - addresses getAddress(): Address [1..2] getCity(): String homeAddr : Address johnSmith :Customer Object diagram officeAddr : Address

  4. What can be classes? • Traditionally… • Nouns in a specification • Each class’s instances/objects should have its own identity, behavior and state. • Physical/logical objects • Identifier for each physical/logical object • People, organizations • Person’s and organization’s roles • Places and locations • Transactions made among classes • Events

  5. Video rental • Each customer can rent up to 10 video tapes. • Each video tape has its own ID.

  6. Video rental • Each customer can rent up to 10 video tapes. • Each video tape has its own ID. Customer VideoTape tapesRented: VideoTape[0..10] - id: int - title: String - rented: boolean 1 0..10 isRented(): boolean rent(): void

  7. Customer VideoTape tapesRented: VideoTape[0..10] - id: int - title: String - rented: boolean Class diagram 1 0..10 isRented(): boolean rent(): void : VideoTape a :Customer 00 :id “Spiderman” :title true : rented Object diagram : VideoTape 10 :id “Spiderman2” :title true : rented : VideoTape b :Customer 01 :id “Spiderman” :title true : rented

  8. What if… • you need to maintain individual video’s properties? • Rental cost, # of rentals, production company, distribution company, distribution year, director’s name, rating (R-rated, PG13, etc.), etc.

  9. Customer VideoTape tapesRented: VideoTape[0..10] - id: int - title: String - rented: boolean - rentalCost: double - directorName:String - numRental: int 1 0..10 Class diagram isRented(): boolean rent(): void : VideoTape a :Customer 00 :id “Spiderman” :title true : rented 1.00: rentalCost “…” : directorName 1: numRental Object diagram : VideoTape b :Customer 01 :id “Spiderman” :title true : rented 1.00: rentalCost “…” : directorName 10: numRental

  10. How can we remove the redundancy?

  11. How can we remove the redundancy? • Separate the properties of individual video tapes and video titles.

  12. Title VideoTape - id: int - title: String - rentalCost: double - directorName:String … - tapeId: int - rented: boolean - numRental: int 1 0..* Class diagram isRented(): boolean rent(): void 0..10 Customer 1 : VideoTape a :Customer 00 :id true : rented 1: numRental : Title Object diagram 001 :id “Spiderman” :title 1.00: rentalCost “…” : directorName : VideoTape b :Customer 01 :id true : rented 10: numRental

More Related