Software Construction: Object-Oriented Design Flashcards
A call-stack is formed when
one method calls another.
Exception mechanisms in a programming language let us
write code to recover from errors, and resume normal execution of the code.
Throwing the exception object causes
an alternate return path to be taken: once an exception is thrown, none of the subsequent code in that method is executed. Instead, the exception object can be thought of as falling back down the return path to the calling method
Normal execution through the normal return path does not
resume until the exception is caught. If the exception is not caught it keeps falling down the alternate exceptional path until the program effectively crashes.
A method should only catch an exception if it can actually
do the work to recover from (handle) that exception.
unchecked exceptions and checked exceptions
unchecked doesnt check by java, checked - checked
To Extract a class hierarchy
we look at all the “extends” and “implements” relationships between classes and interfaces in our system.
To Extract associations
we look at the fields within the classes.
If a class contains a field of another type, then... We would draw the association on the diagram, and indicate...
...we say that the class is associated with that other type. ...what the arity of the association i
An Aggregation relationship can be thought of as
a whole-part relationship. If one object is part of another object, then we use a diamond at the start of the arrow (next to the containing object), and a normal arrow at the end.
A sequence diagram depicts
the calls between objects while the system is running. It’s essentially a vertical timeline of calls, that flows from top to bottom.
A sequence diagram starts
with a particular method call – so effectively, we are drawing the sequence of calls triggered by one method.
At the top of the diagram,
all the objects that are “alive” through the execution of the method are depicted. They then have lifelines (timelines) extending down from them.
To show a method’s execution on the timeline, we draw
a box that overlays the timeline. The box extends for as long as that method runs.
Calls to a method are depicted as
arrows with the name of the method sitting as the label. Parameters are listed in parentheses. The destination object for a call is the object in which that method is implemented. The call arrow extends from the calling object’s method to the called method.
Loops are shown in sequence diagram by
placing a box around all the looped behaviour, and putting the condition of the loop in the corner.