CpSc 372

Exam 2

 

Name______________________________________________

 

Answer any FOUR of the five questions. Place a large X on the question you are omitting. If you answer all five, the one on which you score the best will NOT be counted. All questions are counted the same: 25 points each. Answer all parts of each question. You will need a picture ID to turn in your exam.

 

You can have a laptop in the exam. You may have the textbook, class notes, handouts, copies of submitted homework. You have from 12:30 pm until 1:45pm for the exam.


  1. UML provides a means of describing a design.
    1. How is abstraction useful when you are creating a design? How does UML support abstraction? How does Java support abstraction?

 

    1. We have used the UML interface element, the Java interface construct, and we have the notion of a user interface to a system. How are these the same and how are they different?

 

    1. Describe the relationships between the class diagram, state diagram, and sequence diagram.

 

 

Abstraction is useful because it allows the designer to eliminate certain details and focus on essential ideas. UML supports abstract class definitions and it supports the separation of specification and implementation. Java has an abstract keyword for defining classes. Java also has an interface construct.

 

In all cases an interface hides complexity of implementation. The GUI has nice buttons rather than having a user invoke methods. They are different in that they have support at various levels of abstraction.

 

Each class has a state machine. The state machine defines a set of sequences that can be captured in sequence diagrams. The transitions in the state machine correspond to the methods defined in the class.

  1. The Liskov Substitutability Principle says “if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program”. Assume that we want our design to obey this principle.
    1. How does class inheritance facilitate this principle?

 

    1. What is the relationship between the pre-condition of a method in class S to the pre-condition on the same method in Class T?  Why must that relationship hold if we want the substitutability principle to hold?

 

    1. Does modularity enhance or degrade the usefulness of the principle?

 

Class inheritance provides a relationship among type definitions that allow instances of one type to be recognized as legitimate substitutes for another type.

 

The pre-condition in class S cannot require anymore than the pre-condition in class T. This is because if we want to substitute an instance of S in place of an instance of T the instance of S cannot expect anything additional.

 

Modularity enhances the principle because the principle requires a clearly specified unit that is to be substituted for and a clearly specified unit to be the substitute.

  1. Below is the state diagram for a simple vending machine.

 

    1. Draw one sequence diagram that is possible for a system whose state machine is like the one given below.

 

    1. Write the full transition specification for the Cancelled transition from PaymentAccepted to Idle.

 

    1. List two forms of hierarchy we have used in our design, describe how we used them, and list the attributes that are enhanced and degraded.

 

 

 

 

 

 

 

 

Cancel\[total>0]\{total=0; return total@pre;}

 

 

We have inheritance hierarchies and aggregation hierarchies. Inheritance hierarchies are used to build flexible designs that allow substitutions. Aggregation hierarchies allow the implementation of an element to contain instances of other elements whose implementations include instances of elements. Each of these types of hierarchy enhances the flexibility and modifiability of the system while degrading performance.

  1. We have used three notations: SysML, UML, and AADL during the semester. We have also used Java as the most concrete representation.
    1. Take the concept of two design elements interacting and trace it through all four notations. How does that element stay the same and how does it change?

 

    1. Explain the role of a constraint in a UML diagram. Where do constraints show up on the state diagram in question3?

 

    1. Explain the differences in the roles of people who use each notation. How do they communicate with each other?

 

Two associated blocks in a SysML block diagram leads to multiple system definitions in AADL with interactions between some of those. Each system will generate multiple classes in UML some of which will be associated and have interactions. Those classes are then implemented in Java and the associations are implemented as methods in the classes.

 

A constraint establishes requirements for the element to which it is attached. The guard on any transition in the state diagram is a constraint.

 

The scope of interest changes as the notation changes. The Systems Engineer views the entire system, the Architect views the entire software but not the hardware and the Designer remains focused on a portion of the software. They communicate by translations of the models from one notation to another.

  1. We have used several design patterns in our design of the vending machine.
    1. We used the listener pattern in our implementation of the user interface of the hardware. What did this do for our design? Which attributes are enhanced and which are degraded?

 

    1. We used the singleton pattern. Where is it used and why?

 

    1. Consider the 4 major phases of RUP: Inception, Elaboration, Construction, and Transition. What is the role of testing in each of these phases? List specific testing activities in each phase.

 

The listener pattern decoupled the hardware from the software. It allowed easy changes on both sides. Modifiability was enhanced. Performance degraded.

 

Each machine driver is singleton so that there is no chance to have multiple drivers communicating with one piece of hardware.

 

Inception: test planning

Elaboration: test specification

Construction: test implementation and execution

Transition: Acceptance testing