Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 6 Recap CSE 115 Spring 2007. Review We have built a program that uses Association, Composition, Instantiation Dependency, Local Instance Dependency,

Similar presentations


Presentation on theme: "Week 6 Recap CSE 115 Spring 2007. Review We have built a program that uses Association, Composition, Instantiation Dependency, Local Instance Dependency,"— Presentation transcript:

1 Week 6 Recap CSE 115 Spring 2007

2 Review We have built a program that uses Association, Composition, Instantiation Dependency, Local Instance Dependency, and Realization It also uses JButtons and ActionListeners.

3 Local Instance Dependency Another form of dependency. Difference is that a local variable is used when creating the object being used. The UML arc is the same, but the code looks slightly different.

4 ClassA uses a Class B (with local instance dependency) public class ClassA { public ClassA() { ClassB b = new ClassB(); }

5 Talking to “Current” Pair of Bouncing Balls We discussed how to get our program to talk to the newest created pair of bouncing balls. Our solution involved an intermediary object that would hold on to which pair of balls was the most recently created.

6 Talking to “Current” Pair of Bouncing Balls The buttons talked to that intermediary to learn what the current pair was. When a new pair was created, the button told the intermediary about the new pair.

7 Holder Design Pattern We found out that our design actually used the Holder Design Pattern. Design Patterns are discussed in greater detail in the second half of Chapter 5 of the text. We will be discussing other patterns next week and you will begin to see them in lab assignments.

8 A Deeper Look at the Holder Notice that the code for the holder has two methods other than the constructor. One is a “get” method and the other is a “set” method. These methods are special types of methods called accessors & mutators

9 Accessors & Mutators Special methods inside of a class that work with the instance variables to provide the value of the instance variable and to change the value of the instance variable respectively.

10 Accessors (get methods) Access the value of an instance variable. public TypeOfProperty getProperty(){ return _instanceVariableName; }

11 Mutators (set methods) Change the value of an instance variable. public void setProperty (TypeOfProperty newValue) { _instanceVariableName = newValue ; }


Download ppt "Week 6 Recap CSE 115 Spring 2007. Review We have built a program that uses Association, Composition, Instantiation Dependency, Local Instance Dependency,"

Similar presentations


Ads by Google