r st t t rs

r st t t rs - PowerPoint PPT Presentation

t r r t rs r trt


  1. ❙t❛♥❞✲✉♣ ❢♦r ②♦✉r ♠❡❡t✐♥❣ ♥♦✇✦ ❚♦❞❛②✿ ❯♥✐✜❡❞ ▼♦❞❡❧✐♥❣ ▲❛♥❣✉❛❣❡ ✭❯▼▲✮ ❉✐❛❣r❛♠s ❢♦r ❖❜❥❡❝t✲❖r✐❡♥t❡❞ ✭❖❖✮ ❉❡s✐❣♥ ✶ ❆❣❡♥❞❛ ❉♦ ②♦✉r ✶st t❡❛♠ ♣✐t❝❤ ♦♥ ❚❤✉rs❞❛②

  2. ❚♦❞❛②✿ ❯♥✐✜❡❞ ▼♦❞❡❧✐♥❣ ▲❛♥❣✉❛❣❡ ✭❯▼▲✮ ❉✐❛❣r❛♠s ❢♦r ❖❜❥❡❝t✲❖r✐❡♥t❡❞ ✭❖❖✮ ❉❡s✐❣♥ ✶ ❆❣❡♥❞❛ ❉♦ ②♦✉r ✶st t❡❛♠ ♣✐t❝❤ ♦♥ ❚❤✉rs❞❛② ❙t❛♥❞✲✉♣ ❢♦r ②♦✉r ♠❡❡t✐♥❣ ♥♦✇✦

  3. ❆❣❡♥❞❛ ❉♦ ②♦✉r ✶st t❡❛♠ ♣✐t❝❤ ♦♥ ❚❤✉rs❞❛② ❙t❛♥❞✲✉♣ ❢♦r ②♦✉r ♠❡❡t✐♥❣ ♥♦✇✦ ❚♦❞❛②✿ ❯♥✐✜❡❞ ▼♦❞❡❧✐♥❣ ▲❛♥❣✉❛❣❡ ✭❯▼▲✮ ❉✐❛❣r❛♠s ❢♦r ❖❜❥❡❝t✲❖r✐❡♥t❡❞ ✭❖❖✮ ❉❡s✐❣♥ ✶

  4. ❯♥✐✜❡❞ ▼♦❞❡❧✐♥❣ ▲❛♥❣✉❛❣❡ ✭❯▼▲✮ ❉✐❛❣r❛♠s ❢♦r ❈❧❛ss❡s✱ ❖❜❥❡❝ts✱ ❛♥❞ ❙❡q✉❡♥❝❡s ❈❙✸✼✵ ❙♦❢t✇❛r❡ ✫ ❙t❛rt✉♣ ❊♥❣✐♥❡❡r✐♥❣ Pr❛❝t✐❝✉♠✱ ❈❡♥❣✐③ ●ü♥❛② ✭❙♦♠❡ s❧✐❞❡s ❝♦✉rt❡s② ♦❢ ❊✉❣❡♥❡ ❆❣✐❝❤st❡✐♥ ❛♥❞ t❤❡ ■♥t❡r♥❡ts✳ ▲✐❝❡♥s❡✿ ❈❈ ❇❨✲❙❆ ✹✳✵✳✮ ❈❙✸✼✵✱ ●ü♥❛② ✭❊♠♦r②✮ ❯▼▲ ❉✐❛❣r❛♠s ❙♣r✐♥❣ ✷✵✶✺ ✸ ✴ ✶✷

  5. ▼❡t❤♦❞s✴❢✉♥❝t✐♦♥s ❉❛t❛ ♠♦❞❡❧✿ ❊♥t✐t②✲r❡❧❛t✐♦♥s❤✐♣ ✭❊❘✮ ❞✐❛❣r❛♠s ❊♥t✐t✐❡s ❆ttr✐❜✉t❡s ❘❡❧❛t✐♦♥s❤✐♣s ✭❛❣❣r❡❣❛t✐♦♥✱ ♠✉❧t✐♣❧✐❝✐t②✱ ✳ ✳ ✳ ✮ ❲❤❛t✬s ♠✐ss✐♥❣❄ ❈❙✸✼✵✱ ●ü♥❛② ✭❊♠♦r②✮ ❯▼▲ ❉✐❛❣r❛♠s ❙♣r✐♥❣ ✷✵✶✺ ✹ ✴ ✶✷

  6. ❉❛t❛ ♠♦❞❡❧✿ ❊♥t✐t②✲r❡❧❛t✐♦♥s❤✐♣ ✭❊❘✮ ❞✐❛❣r❛♠s ❊♥t✐t✐❡s ❆ttr✐❜✉t❡s ❘❡❧❛t✐♦♥s❤✐♣s ✭❛❣❣r❡❣❛t✐♦♥✱ ♠✉❧t✐♣❧✐❝✐t②✱ ✳ ✳ ✳ ✮ ❲❤❛t✬s ♠✐ss✐♥❣❄ ▼❡t❤♦❞s✴❢✉♥❝t✐♦♥s ❈❙✸✼✵✱ ●ü♥❛② ✭❊♠♦r②✮ ❯▼▲ ❉✐❛❣r❛♠s ❙♣r✐♥❣ ✷✵✶✺ ✹ ✴ ✶✷

  7. ◆♦✇ ✇❡✬❧❧ ❧❡❛r♥ ❤♦✇ t♦ ❞❡♣✐❝t ❝❧❛ss❡s ✐♥ ❞✐❛❣r❛♠s ✇✐t❤ ❯▼▲ ❈❧❛ss❡s✿ ❊♥❝❛♣s✉❧❛t❡ ❉❛t❛ ✰ ▼❡t❤♦❞s ❖❜❥❡❝t✲♦r✐❡♥t❡❞ ✭❖❖✮ ♣r♦❣r❛♠♠✐♥❣ ♣r✐♥❝✐♣❧❡s✿ ❯s❡❞ ❜② ❛❧❧ ♠❛✐♥str❡❛♠ s♦❢t✇❛r❡ t♦❞❛② ◆♦t ❤❛✈❡ ❛ ❣♦♦❞ ❣r❛s♣ ❢♦r ✐t❄ ❲❛t❝❤ t❤✐s ❧❡❝t✉r❡✿ ❤tt♣s✿✴✴✇✇✇✳②♦✉t✉❜❡✳❝♦♠✴✇❛t❝❤❄✈❂❉❞❯❙③❏✽t❛▼s ❈❙✸✼✵✱ ●ü♥❛② ✭❊♠♦r②✮ ❯▼▲ ❉✐❛❣r❛♠s ❙♣r✐♥❣ ✷✵✶✺ ✻ ✴ ✶✷

  8. ❈❧❛ss❡s✿ ❊♥❝❛♣s✉❧❛t❡ ❉❛t❛ ✰ ▼❡t❤♦❞s ❖❜❥❡❝t✲♦r✐❡♥t❡❞ ✭❖❖✮ ♣r♦❣r❛♠♠✐♥❣ ♣r✐♥❝✐♣❧❡s✿ ❯s❡❞ ❜② ❛❧❧ ♠❛✐♥str❡❛♠ s♦❢t✇❛r❡ t♦❞❛② ◆♦t ❤❛✈❡ ❛ ❣♦♦❞ ❣r❛s♣ ❢♦r ✐t❄ ❲❛t❝❤ t❤✐s ❧❡❝t✉r❡✿ ❤tt♣s✿✴✴✇✇✇✳②♦✉t✉❜❡✳❝♦♠✴✇❛t❝❤❄✈❂❉❞❯❙③❏✽t❛▼s ◆♦✇ ✇❡✬❧❧ ❧❡❛r♥ ❤♦✇ t♦ ❞❡♣✐❝t ❝❧❛ss❡s ✐♥ ❞✐❛❣r❛♠s ✇✐t❤ ❯▼▲ ❈❙✸✼✵✱ ●ü♥❛② ✭❊♠♦r②✮ ❯▼▲ ❉✐❛❣r❛♠s ❙♣r✐♥❣ ✷✵✶✺ ✻ ✴ ✶✷

  9. UML class diagrams • What is a UML class diagram? What does it represent? – A picture of the classes in an OO system, their fields and methods, and connections between the classes that interact or inherit from each other • What are some things not represented in a class diagram? – details of how the classes interact – algorithmic details; how particular behavior is implemented – trivial methods (get/set) – classes that come from libraries (ArrayList, etc.)

  10. Diagram of one class • class name in top of box – write <<interface>> above interfaces' names – use italics for an abstract class name • attributes – should include all fields of the object – also includes derived “properties” • operations / methods – may omit trivial (get/set) methods – should not include inherited methods

  11. Class attributes • attributes (fields, instance variables) – visibility: + public # protected - private ~ package (default) / derived – underline static attributes • derived attribute : not stored, but can be computed from other attribute values

  12. Class operations / methods • operations / methods – visibility name ( parameters ) : returnType – underline static methods – parameter types listed as (name: type) – omit returnType on constructors and when return is void

  13. Comments • represented as a folded note, attached to the appropriate class/method/etc by a dashed line

  14. Relationships between classes • generalization : an inheritance (is-a) relationship – inheritance between classes – interface implementation • association : a usage (is-part-of) relationship – dependency – aggregation – composition

  15. Generalization relationships • Hierarchies drawn top-down with arrows pointing upward to parent • Line/arrow styles differ based on parent – class : solid, black arrow – abstract class : solid, white arrow – interface : dashed, white arrow • Trivial / obvious relationships, such as drawing the class Object as a parent, are generally omitted

  16. Associational relationships 1. multiplicity (how many are used)  0, 1, or more • *  1 exactly • 1  between 2 and 4, inclusive • 2..4  3 or more • 3..* 2. name (what relationship the objects have) 3. navigability (direction)

  17. Multiplicity • one-to-one – Ex: each student must have exactly one ID card • one-to-many – a RectangleList can contain 0, 1, 2, ... rectangles

  18. Association types Car 1 • aggregation : "is part of" 1 Engine – clear white diamond • composition : "is entirely made Book of" – stronger version of aggregation 1 – the parts live and die with the * whole Page – black diamond • dependency : "uses temporarily" Lottery Random – dotted line or arrow Ticket – often is an implementation

  19. Multiplicity Customer Simple 1 Class Aggregation Rental Invoice Abstract Class 1..* Rental Item 1 0..1 Composition Simple Generalization Association Checkout Screen DVD Movie VHS Movie Video Game

  20. Student dentBody Body Student dent 1 100 - firstName me : S String - lastNam ame : S String + main (args : S String[ g[]) ]) - homeAddr Addres ess : A Addres ess - school oolAddr Addres ess : A Addres ess + toString( ng() : S String Addr dress ess - streetAddr tAddress ess : S String - city : S String - state : S String - zipCode de : l long + toString( ng() : S String

  21. ❲❤✐❝❤ t❡❛♠s ❤❛✈❡ t❤♦✉❣❤t ♦❢ ❛♥ ♦❜❥❡❝t ♠♦❞❡❧❄ ❈♦♥s✉❧t ✇✐t❤ ②♦✉r t❡❛♠ t♦ ✐❞❡♥t✐❢② ♠❛❥♦r ♦❜❥❡❝ts ✐♥ ②♦✉r ♣r♦❥❡❝t ✭❲✐❧❧ ❜❡ ♠❛♥❞❛t♦r② ✐♥ ♥❡①t ✐t❡r❛t✐♦♥✮ ❖❖ ✐♥ ②♦✉r ♣r♦❥❡❝ts ❲❤✐❝❤ t❡❛♠s ❛r❡ ♣r❡s❡♥t✐♥❣ ❞❛t❛ ♠♦❞❡❧s❄

  22. ❈♦♥s✉❧t ✇✐t❤ ②♦✉r t❡❛♠ t♦ ✐❞❡♥t✐❢② ♠❛❥♦r ♦❜❥❡❝ts ✐♥ ②♦✉r ♣r♦❥❡❝t ✭❲✐❧❧ ❜❡ ♠❛♥❞❛t♦r② ✐♥ ♥❡①t ✐t❡r❛t✐♦♥✮ ❖❖ ✐♥ ②♦✉r ♣r♦❥❡❝ts ❲❤✐❝❤ t❡❛♠s ❛r❡ ♣r❡s❡♥t✐♥❣ ❞❛t❛ ♠♦❞❡❧s❄ ❲❤✐❝❤ t❡❛♠s ❤❛✈❡ t❤♦✉❣❤t ♦❢ ❛♥ ♦❜❥❡❝t ♠♦❞❡❧❄

  23. ❖❖ ✐♥ ②♦✉r ♣r♦❥❡❝ts ❲❤✐❝❤ t❡❛♠s ❛r❡ ♣r❡s❡♥t✐♥❣ ❞❛t❛ ♠♦❞❡❧s❄ ❲❤✐❝❤ t❡❛♠s ❤❛✈❡ t❤♦✉❣❤t ♦❢ ❛♥ ♦❜❥❡❝t ♠♦❞❡❧❄ ❈♦♥s✉❧t ✇✐t❤ ②♦✉r t❡❛♠ t♦ ✐❞❡♥t✐❢② ♠❛❥♦r ♦❜❥❡❝ts ✐♥ ②♦✉r ♣r♦❥❡❝t ✭❲✐❧❧ ❜❡ ♠❛♥❞❛t♦r② ✐♥ ♥❡①t ✐t❡r❛t✐♦♥✮

Recommend


More recommend