1 / 79

Object-Oriented Programming: Intermediate Concepts

Learn intermediate concepts in object-oriented programming, including object structure, collaboration, and following the OOP paradigm.

lancef
Download Presentation

Object-Oriented Programming: Intermediate Concepts

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. WARNING • These slides are not optimized for printing or exam preparation. These are for lecture delivery only. • These slides are made for PowerPoint 2010. They may not show up well on other PowerPoint versions. You can download PowerPoint 2010 viewer from here. • These slides contain a lot of animations. For optimal results, watch in slideshow mode.

  2. Assume AddressBook is keeping track of all commands executed earlier Command History execute() undo() add(Command) (a) 1 (b) 0..1 (c) * (d) 1..* mul {a|b|c|d} e.g. mul b 77577OR tinyurl.com/answerpost

  3. OOP: Intermediate Concepts CS2103/T, Lecture 4, Part 1, [Sep 2, 2016]

  4. How to structure? Object rules Collaborating objects Object structure Follow a paradigm 1 2 3 4 OOP 1. Abstraction 2. Encapsulation 3. ………….. 4. ……………..

  5. Some more rules How to structure? Object rules Collaborating objects Object structure Follow a paradigm 1 2 3 4 OOP 1. Abstraction 2. Encapsulation 3. ………….. 4. ……………..

  6. borrows Book Student Book Student borrowed by

  7. borrows Book Student Where to put return date?

  8. borrows Book Student Book Student Loan returnDate borrows Association classes

  9. borrows Book Student Book Student Loan Book Student Loan returnDate returnDate borrows Association classes

  10. Book Student Loan returnDate borrows Association classes

  11. Book Student Loan returnDate borrows Association classes

  12. Book Student Loan Chapter returnDate borrows

  13. Book Student Loan Chapter returnDate borrows Composition

  14. Book Student Loan Chapter Shelf returnDate borrows Composition

  15. Book Student Loan Chapter Shelf returnDate borrows Composition Aggregation

  16. Book Chapter Shelf Composition Aggregation

  17. Composition Aggregation

  18. Composition Aggregation

  19. Book Student Loan Chapter Shelf returnDate borrows Aggregation Composition

  20. Book Student Loan Chapter Shelf returnDate borrows Aggregation Composition

  21. Book Student Loan Chapter Shelf returnDate borrows Where to put total students?

  22. Book Loan Chapter Shelf Student returnDate -totalStudents +getTotal() borrows You mean I can say Student.getTotal() ? Class-level members

  23. Book Loan Chapter Shelf Student returnDate -totalStudents +getTotal() borrows You mean I can say Student.getTotal() ? OK. Can I say Student.totalStudents? Class-level members

  24. Book Loan Student returnDate -totalStudents +getTotal() borrows Class-level members

  25. foo bar() Composition Aggregation Association classes Class-level members

  26. How to structure? Object rules Collaborating objects Object structure Follow a paradigm 1 2 3 4 OOP 1. Abstraction 2. Encapsulation 3. ………….. 4. ……………..

  27. Can it give the object structure we need? Is this good to go? Possibly. It follows the real world. History :History TextUi MSLogic Storage :MSLogic :Storage :TextUi Minefield :Minefield ? Square s1:Square s2:Square s3:Square s4:Square m1:Mine Mine m2:Mine Can it give the behavior we need?

  28. The architect

  29. :UI Sequence Diagrams [interactions between components for a given scenario]

  30. :UI operation returned value Sequence Diagrams [interactions between components for a given scenario]

  31. :UI

  32. :UI

  33. :UI

  34. :UI

  35. :UI

  36. SD for PC phone 1. User presses digit 2. System shows digit Repeat step 1-2 until telephone number is entered. 3. User press ‘send’ 4. System connects the call. Telephone conversation takes place. 5. User press ‘end’ 6. System disconnects the call Use case ends. :PCPhoneUI User loop [Until full number] press key Shows digit ‘send’ call connected ‘end’ call disconnected

  37. :UI

  38. :UI

  39. :UI :MSLogic

  40. :UI :MSLogic

  41. No. That’s against SRP! I want a foo()

More Related