1 / 69

Lecture 2: UML Class DIAGRAM

CSC 213 – Large Scale Programming. Lecture 2: UML Class DIAGRAM. Today’s Goal. Learn Unified Process to design programs Understand what are the “types ” of Java classes Methods of selecting the potential classes How these designs presented for others to use. Classroom Development.

anthea
Télécharger la présentation

Lecture 2: UML Class DIAGRAM

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. CSC 213 – Large Scale Programming Lecture 2:UML Class DIAGRAM

  2. Today’s Goal • Learn Unified Process to design programs • Understand what are the “types” of Java classes • Methods of selecting the potential classes • How these designs presented for others to use

  3. Classroom Development • Always start from scratch • Know all requirements from the start • And requirements will not change • Coding begins immediately at start • Projects are trivial jokes in real-world • If lasts 15 weeks, project “large scale” • Code cannot be reused • Never look at again, anyway

  4. Why These Phases Matter

  5. Our Goal

  6. Our Nemesis

  7. Other Nemesis

  8. Other Nemesis

  9. Where We Start

  10. Find the Classes • Designing classes next step in process • Could help find & fix inconsistent requirements • Requirements clarified if you do not understand them • Outlining classes makes coding easy • Already know methods to call from other classes • Will provide chance to do some easy debugging

  11. Noun Extraction • Finds entity class candidates to be used in design • Initial pass may (will) not find all entity classes • Some classes not used even though found early on • Provides strong hints for other needed classes • Start with plain English requirements • Should be easy & comes with most assignments • Many nouns not needed, so can prune list • Eliminate any & all classes external to program

  12. Designing Elevator Controller Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.

  13. Noun Extraction 1. Underline the nouns in the requirements Buttons in elevators and on the floors control the movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator stop at a specific floor; the illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.

  14. Noun Extraction 1. Underline the nouns in the requirements Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  15. Noun Extraction 2. Eliminate nouns external to the problem Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  16. Noun Extraction 2. Eliminate nouns external to the problem Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  17. 3 “Types” of Classes • Unified Process concept simplifies design process • Entity classeshold long-lived data driving program • Input & output handled by boundary classes • Control classesdo complex processing in program • "Types" not real, exist for design purposes only • A class is a class is a class within Java & program • But they can help checking design covers all needs

  18. Entity Classes

  19. Entity Classes • Focus on entity classes & ignore (for now)others • Since not things, prune abstract (non-physical) nouns • Ignore if used for communication – rarely drive program • Thinking will change -- must work iteratively • Writing & debugging easier given good design • Minutes spent in design saves hours in coding & testing

  20. “Must work iteratively” !=

  21. Find Entity Classes Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  22. Find Entity Classes 1. Ignore abstract (non-physical) nouns Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  23. Find Entity Classes 1. Ignore abstract (non-physical) nouns Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  24. Find Entity Classes 2. Only use singular form of each noun Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  25. Find Entity Classes 2. Only use singular form of each noun Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  26. Our Entity Classes Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed. Button Floor Elevator

  27. Boundary Classes • These classes will perform all input & output • May have many details which are all independent • Only 1 detail known: it will change before its over • Make class for each detail & limit future rewriting • Make life easier, start from simplest ideas • Easy to combine simple classes to create complex ones • Taking a complex class and breaking up far harder • Rarely rewrite complex classes because of difficulty…… instead often just throw out & start from scratch

  28. Skipping Boundary Classes • Boundary classes may duplicate primitive type • Can eliminate this class; it adds nothing to design • Code will have primitive hard-coded everywhere • Saves writing javadoc for class, field, getter & setter • When needs change and class now needed…

  29. Skipping Boundary Classes • Boundary classes may duplicate primitive type • Can eliminate this class; it adds nothing to design • Code will have primitive hard-coded everywhere • Saves writing javadoc for class, field, getter & setter • When needs change and class now needed… • Find & replace all primitives littering code • Scan entire program to track down all I/O for this data • Retest entire application to ensure now bugs created

  30. Skipping Boundary Classes • Boundary classes may duplicate primitive type • Can eliminate this class; it adds nothing to design • Code will have primitive hard-coded everywhere • Saves writing javadoc for class, field, getter & setter • When needs change and class now needed… • Find & replace all primitives littering code • Scan entire program to track down all I/O for this data • Retest entire application to ensure now bugs created • Industry usually finds better writing class at start

  31. Find Boundary Classes 1. Reexamine abstract nouns & keep if used in I/O Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  32. Find Boundary Classes 1. Reexamine abstract nouns & keep if used in I/O Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  33. Find Boundary Classes 2. Only use singular form of each noun Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  34. Find Boundary Classes 3. There is no step 3 Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  35. I Know Boundary Classes! 3. There is no step 3 Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed. Movement Request Illumination

  36. Control Classes • Non-obvious algorithms using many classes • Rule of thumb: obvious algorithm have name • Control classes already exist for named algorithms • Needed for those plurals ignored previously • Can use array or enum, if exact number known • Else, design needs structure to hold instances

  37. Control Classes • Non-obvious algorithms using many classes • Rule of thumb: obvious algorithm have name • Control classes already exist for named algorithms • Needed for those plurals ignored previously • Can use array or enum, if exact number known • Else, design needs data structure to hold instances

  38. Control Classes • Non-obvious algorithms using many classes • Rule of thumb: obvious algorithm have name • Control classes already exist for named algorithms • Needed for those plurals ignored previously • Can use array or enum, if exact number known • Else, design needs data structure to hold instances • CSC212 & CSC213 focus: future control classes • CSC213 will discuss many “obvious” algorithms • Important data structures developed in both courses

  39. Finding Control Classes! 1. Reexamine plurals & keep when necessary Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  40. Finding Control Classes! 1. Reexamine plurals & keep when necessary Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  41. Finding Control Classes! 2. Eliminate if constant number (array) needed Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  42. Finding Control Classes! 2. Eliminate if constant number (array) needed Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  43. Finding Control Classes! 2. Eliminate if constant number (array) needed Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  44. Finding Control Classes! 3. Select data structure to use for each plural Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed.

  45. Finding Control Classes! 3. Select data structure to use for each plural Buttonsinelevatorsand on the floorscontrol the movementof nelevatorsin abuildingwith mfloors. Buttonsilluminate when pressed to request theelevatorstop at a specific floor; the illuminationis canceled when the requesthas been satisfied. When anelevatorhas no requests, it remains at its current floorwith its doorsclosed. PriorityQueue

  46. Now Determine Fields in Design • Designing classes next step in process • For each class, determine fields • Link classes that work together so easy to code • When done well, coding becomes relatively simple • What should be fields & how can we know? • Since they are abstract, boundary classes often fields • Control classes often fields; something must use it • Read text again: look where one noun posses another

  47. What To Do Next? • Must communicate design in clear way to others • Make explicit what the classes for this program are • Identify fields & other relationships between classes • Make certain information is clearly highlighted • Provides vital check that can often find bugs • Will do this by drawing pretty pictures

  48. What To Do Next? • Must communicate design in clear way to others • Make explicit what the classes for this program are • Identify fields & other relationships between classes • Make certain informationis clearly highlighted • Provides vital check that can often find bugs • Will do this by drawing pretty pictures

  49. Pictures Worth 1,000 Words

  50. Pictures Worth 1,000 Words

More Related