1 / 95

WARNING

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 .

soyala
Télécharger la présentation

WARNING

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. Design (a)

  3. Design (a)

  4. Design (b)

  5. Design (b)

  6. Design (c)

  7. Design (c)

  8. Design (c)

  9. Design (c)

  10. Book copies in a library TV drama episodes Video copies in a rental shop

  11. Book copies in a library TV drama episodes Video copies in a rental shop

  12. Book copies in a library TV drama episodes Video copies in a rental shop   

  13. • Book copies in a library • TV drama episodes • Video copies in a rental shop    Recurring tasks in a schedule

  14. Déjà vu: Using patterns to solve recurring problems CS2103/T, Lecture 8, Part 1, [Oct 11, 2013]

  15. Déjà vu: Using patterns to solve recurring problems

  16. experience Déjà vu: Usingpatterns to solve recurring problems

  17. experience … is what you get when you didn’t get what you wanted.

  18. experience … is valuable.

  19. Learning from experience … is too costly.

  20. Learning from experience Note to self: never volunteer to be the headstand guy

  21. Learning from experience Patterns

  22. Context:Multiple stock items of same TV model • Problem: Same data (but not all) shared among stock items of the same model. • Solution: Represent TV model andTV stock item as different classes.

  23. Context:Multiple stock items of same TV model • Problem: Same data (but not all) shared among stock items of the same model. • Solution: Represent TV model andTV stock item as different classes. • Stock items • Book copies in a library • TV drama episodes • …

  24. Context: Multiple stock items of same TV model • Problem: Same data (but not all) shared among stock items of the same model. • Solution: Represent TV model andTV stock item as different classes.

  25. Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes.

  26. Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. * <<Abstraction>> <<Occurrence>>

  27. Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. * <<Abstraction>> <<Occurrence>>

  28. TVModel BookTitle Lesson * * * TVStockItem BookCopy LessonDelivery * <<Abstraction>> <<Occurrence>>

  29. TVModel BookTitle Lesson * * * TVStockItem BookCopy LessonDelivery * <<Abstraction>> <<Occurrence>>

  30. Name: Abstraction Occurrence Pattern • Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. * <<Abstraction>> <<Occurrence>>

  31. Name: Abstraction Occurrence Pattern • Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. * <<Abstraction>> <<Occurrence>> Pattern [An elegant solution to a recurring problem]

  32. Name: Abstraction Occurrence Pattern • Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. * <<Abstraction>> <<Occurrence>> Pattern [An elegant solution to a recurring problem]

  33. Name: Abstraction OccurrencePattern • Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. * <<Abstraction>> <<Occurrence>>

  34. … for that, I used the Name: Abstraction OccurrencePattern • Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. Show off ! * * <<Abstraction>> <<Abstraction>> <<Occurrence>> <<Occurrence>>

  35. Patterns = a high-level vocabulary

  36. Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction.

  37. Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. Anti-Pattern [A stupid solution to a recurring problem]

  38. Context: Multiple occurrences of some abstraction • Problem: Same data (but not all) shared among occurrences of the same abstraction. • Solution: Represent abstraction and occurrences as different classes. Anti-Pattern [A stupid solution to a recurring problem]

  39. 1. Abstraction occurrence 2. Singleton 3. Façade 4. Command 5. MVC 6.Observer

  40. 1. Abstraction occurrence 2. Singleton 3. Façade 4. Command 5. MVC 6.Observer

  41. 1. Abstraction occurrence 2. Singleton3. Façade 4. Command 5. MVC 6.Observer Context: one-and-only-one object, shared among others

  42. 1. Abstraction occurrence 2. Singleton3. Façade 4. Command 5. MVC 6.Observer Context: one-and-only-one object, shared among others Problem: how to avoid multiple objects?

  43. 1. Abstraction occurrence 2.Singleton3. Façade 4. Command 5. MVC 6.Observer Solution: Logic - Logic( ) + getInstance( ) : Logic

  44. 1. Abstraction occurrence 2.Singleton3. Façade 4. Command 5. MVC 6.Observer Solution: Logic -theOne : Logic - Logic( ) + getInstance( ) : Logic

More Related