Week 13 Flashcards
- Implementation Hiding means
o Hiding the details of how a method works
- Method cohesion
o A measure of how the internal statements serve to accomplish the methods purpose
- A method with high cohesion has all of it’s ________ operarions
o Has all its internal operations focused on one task or goal
- Low cohesion method traits
o Tries to do too many things
- noticeable high cohesion method traits
o Easy to read, maintain, reliable
o How much methods are connected/share information
- Method Coupling
- Methods that are interdependent on each other have
o Tight coupling
- Methods that are not interdependent
o Loose coupling
o Can be called in any order
- Tightly coupled methods are known to use _____ level variables
o class
- Tightly coupled methods are ____ to understand, and hard to ________
o Hard, maintain
- T/F - Tightly coupled methods often have to be called in a certain order to work properly
o True
- T/F – Global variables should be avoided to prevent tight coupling
o True (although Java does not have global vars, closest thing is a public class var)
- T/F – A method with tight coupling and low cohesion is strong
o False
- The word fragile is used to describe tight coupling and low cohesion
o True
- What makes a good class?
o Represents a single concept
- Bad class design
o Name does not tell you what it does
- If the name of the class is a noun but a verb instead, you are making a mistake, why?
o You should be making a method instead of a class
- Public methods for a class should be related to
One single concept from the domain of what the class represents
o If one class needs to call methods from another class it’s referred to as
Object dependency
o Placing method calls to java API also creates ______ ___________
method dependencies
- Program outputs are best handled with a
o Dedicated output class
o If you omit mutators from your class it becomes _________
immutable
o An immutable class cannot be
Changed after it has been created
o Advantage of immutable objects? They can be freely references in
They can be freely referenced in many places in a program, nothing can change its state unexpectedly
o Mutable classes should follow the guideline: any method that accesses the objects values
Should never change the object
o Public methods are collectively referred to as
Class-interface
o When program logic places a method call it should only need to know
The method name, parameters, and data to be returned