Tina Comston Comp-111 Week 13 Franklin University |
||||
Week 13 | ||||
Preparation
|
||||
Guided
Learning Activity |
||||
Assignment
Mutable versus Immutable Classes A
few weeks ago mutable (mutator) versus immutable (accessor) methods
were discussed. A mutable method makes changes to the instance
variables of an object. An immutable method does not. It is possible to have both mutable and immutable methods within the same object. When it comes to classes, an immutable class contains only immutable methods - other than the constructor. The constructor will create the object, setting the instance variables to their value, but once created the instance variables cannot be changed. The class contain only immutable methods. A mutable class, on the other hand, contains does allow for modification of the instance variables. It contains mutator methods and most likely also contains immutable methods (accessors). To learn more: http://www.java-questions.com/ImmutableClass-interview-questions.html
Designing Classes When
presented with a problem and trying to determine what classes are
needed, think nouns. A class is a computer version of a real
world entity. A method, on the other hand, is an action, think
verb. Consider a Dog class - a dog is a real world entity. Get age - that's an action. Bark - action, Set - action. Dog would be a class, the others would be methods. Dependency Diagrams Open
lab 4 in BlueJ. Take a look at the initial screen where all of
the classes are listed - that is a dependency diagram. Note
the dashed lines with arrows going from one class to another?
That indicates a dependency. If you reference a class within another class - that indicates a dependency. For example, if there is a Dog class and within the class there is a Date object for the birth date, the Dog class will be dependent upon the Date class. In a dependency diagram this would be represented by a dashed line going from the Dog class and pointing to the Date class. To learn more: http://ourownjava.com/uml/uml-class-diagram-dependencyuses/
Using the Sort Algorithms For a review of the algorithms, see Week 12 Hints & Tips. Before you can use the sort algorithms you first need to determine the following:
|
||||
Reflection
Paper
|
||||
Lab 5
|