1 / 19

Construction

Construction. Lecture Oo21 Gymnastics System Example Cont’d. Teaching Points. Implementation classes Moving from design to code Observer pattern. Review. What is a construction iteration? What is the general process followed in a construction iteration?

edan
Download Presentation

Construction

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. Construction Lecture Oo21 Gymnastics System Example Cont’d

  2. Teaching Points • Implementation classes • Moving from design to code • Observer pattern

  3. Review • What is a construction iteration? • What is the general process followed in a construction iteration? • How can you design a new class that does just-a-bit-more than parameterized class?

  4. How Class Attributes and Operations are Implemented • Detailed designs provide enough detail to imply guidance for implementation. • Names and detailed types for attributes may be supplied • Names, signature (names and type of parameters) and return type for operations may be specified • Specifications provide detail on semantics and algorithms

  5. How Class Relationships are Implemented • When using an Implementation Perspective class relationships imply some guidance for implementation.

  6. Generalization (Inheritance) class RawScoreList { } class TrialScoreList extends RawScoreList { }

  7. Realization interface Enumeration { public Object nextElement(); public bool hasMoreElements(); } class TrialScoreList implements Enumeration { public Object nextElement(){… } public bool hasMoreElements(){… } }

  8. Binding (Instantiation of Parameterized Class - C++) Template<class T> class List{ }; // An example in a local object declaration List<RawScore> aRawScrLst(100); // An example in a free store allocation listPtr = new List<RawScore>(100); // An example in an inheritance declaration class TrailScoreList: public List<RawScore> { };

  9. Composition class Trial{ private double maxScore; private double minScore; }

  10. Aggregation class Trial{ private TrialScoreList scores; //Note: in this case we //think of trial as being //a container for scores }

  11. Association class Trial{ private TrialScoreList scores; //Note: in this case we //think of trial as being //a peer object to the trial //scores list }

  12. Dependency class ResultsGenerator{ public void someMethod(Meet); public Meet someOtherMethod(); public void aThirdMethod(){ Meet aMeet; //Meet as a local object } }

  13. A Gymnastics System Example

  14. You will have to open the PowerPoint file to get all the code: // // File RawScore.java // package dataStructures; public class RawScore { private Score value; } // // File TrialScoreList.java // package contests; import java.util.Vector; class TrialScoreList extends Vector{ public RawScore min(){... } public RawScore max(){... } } // // File Gymnast.java // package people; class Gymnast { private Date birthdate; private bool gender; private String name; } // // File Trial.java // package contests; import people.Gymnast; class Trial { private Gymnast performer; private TrialScoreList scores; public void addScore(RawScore); public Score score(); } // // File Event.java // package contests; import people.EventJudge; import people.Gymnast; import people.team; class Event { private Trial[] trialList; //This is a container for many trials //and probably needs more design work public void addJudge(EventJudge); public Score score(); public Score individualScore(Gymnast); public Score teamScore(Team); public String getTitle(); }

  15. Observer Pattern • Problem • A common side-effect of partitioning a system into a collection of cooperating classes is the need to maintain consistency between related objects. • You don't want to achieve consistency by making the classes tightly coupled, because that reduces their reusability.

  16. Observer Pattern • Solution • Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

  17. Observer Pattern (Structure)

  18. Observer Pattern (Interactions)

  19. Teaching Points • Implementation classes • Moving from design to code • Observer pattern

More Related