Sunday 20 January 2013

Chapter 9: Analysis Classes




True-False Questions

1.      Analysis class diagramming is typically done during requirements structuring.

Answer:    True                 Page Reference:  240                         Difficulty:  Easy


2.      Entity classes are primarily concerned with user interface issues.

Answer:    False                Page Reference:  241                         Difficulty:  Moderate


3.      The responsibility for a message rests with the sender of the message.

Answer:    False                Page Reference:  241-242                  Difficulty:  Moderate


4.      The behavioral responsibilities identified by use cases are typically assigned to control classes.

Answer:    True                 Page Reference:  243                         Difficulty:  Moderate


5.      Message-passing as a time-ordered sequence is represented directly in activity diagrams.

Answer:    False                Page Reference:  243-245, 253-254   Difficulty:  Moderate


6.      In sequence diagrams, a focus-of-control bar represents a period of time during which an object performs an action.

Answer:    True                 Page Reference:  244                         Difficulty:  Moderate


7.      The only type of analysis class allowed to interact with an actor is a boundary class.

Answer:    True                 Page Reference:  250                         Difficulty:  Moderate


8.      Boundary classes typically interact with entity classes.

Answer:    False                Page Reference:  250                         Difficulty:  Moderate


9.      There is no information regarding the sequence of messages in communication diagrams.

Answer:    False                Page Reference:  251                         Difficulty:  Moderate


10.  Flow of control is depicted in activity diagrams.

Answer:    True                 Page Reference:  253                         Difficulty:  Moderate


11.  Synchronization bars in activity diagrams depict sequential flow of control.

Answer:    False                Page Reference:  255                         Difficulty:  Moderate


12.  Activity diagrams should be used to describe all behavior of each object during the analysis phase.

Answer:    False                Page Reference:  255-256                  Difficulty:  Moderate


13.  State diagrams are only useful for describing the behaviors of an object within a single use case.

Answer:    False                Page Reference:  257                         Difficulty:  Moderate


14.  State diagrams are useful for showing communications between objects.

Answer:    False                Page Reference:  257                         Difficulty:  Moderate


15.  All but the most trivial use cases should include data models, analysis classes, and sequence diagrams.

Answer:    True                 Page Reference:  258                         Difficulty:  Moderate


16.  Business rules are held exclusively in entity classes.

Answer:    False                Page Reference:  258                         Difficulty:  Moderate


17.  Constraints such as permissible values and validation rules are mostly used in entity classes.

Answer:    True                 Page Reference:  258-259                  Difficulty:  Moderate


18.  Calculations are usually implemented as methods.

Answer:    True                 Page Reference:  259                         Difficulty:  Moderate


19.  Condition stubs contain the actions that will be taken in a decision table.

Answer:    False                Page Reference:  260                         Difficulty:  Moderate


20.  Action enablers can be represented as decision tables.

Answer:    True                 Page Reference:  260-261                  Difficulty:  Moderate


21.  Although OCL is useful for specifying constraints, it cannot be used for other types of business rules.

Answer:    False                Page Reference:  261                         Difficulty:  Moderate



Multiple-Choice Questions

22.  An ____________ class is one that represents initial data and behavior, without specifying the software- and hardware-oriented details.

a.       implementation
b.      association
c.       application
d.      analysis

Answer: d                         Page Reference:  241                         Difficulty:  Moderate


23.  A class’s responsibility is invoked when an object of the class receives a:

a.       message.
b.      actor.
c.       contract.
d.      transition.

Answer: a                          Page Reference:  242                         Difficulty:  Moderate


24.  ____________ classes are those whose primary focus is to hold persistent data.

a.       Boundary
b.      Relational
c.       Entity
d.      Database

Answer: c                          Page Reference:  242                         Difficulty:  Moderate

25.  When creating analysis classes, each entity class will correspond with a(n):

a.       use case.
b.      actor.
c.       object relation.
d.      transition sequence.

Answer: c                          Page Reference:  242                         Difficulty:  Moderate


26.  ____________ classes are those that provide interaction to the system for actors.

a.       Use case
b.      Boundary
c.       Interface
d.      Control

Answer: b                         Page Reference:  242                         Difficulty:  Moderate


27.  Processing of main application logic and coordination of tasks in a use case is implemented in ____________ classes.

a.       application
b.      use case
c.       coordination
d.      control

Answer: d                         Page Reference:  242-243                  Difficulty:  Moderate


28.  Interaction diagrams illustrate the:

a.       flow of messages between objects.
b.      interactions between users and the system.
c.       steps that take place within an object.
d.      decision points and activity transitions.

Answer: a                          Page Reference:  243                         Difficulty:  Moderate


29.  The UML ____________ diagram is a time-ordered interaction diagram.

a.       activity
b.      message
c.       sequence
d.      communication

Answer: c                          Page Reference:  243                         Difficulty:  Easy

30.  Message implementation is the responsibility of the object:

a.       representing the actor.
b.      controlling the application.
c.       sending the message.
d.      receiving the message.

Answer: d                         Page Reference:  244                         Difficulty:  Moderate


31.  The thin vertical rectangles in a sequence diagram represent an object(s):

a.       message passing.
b.      focus of control.
c.       lifetime.
d.      decision point.

Answer: b                         Page Reference:  244-245                  Difficulty:  Moderate


32.  ____________ analysis involves reviewing use case narratives, identifying boundary, entity, and control classes, and verifying adherence to diagramming rules.

a.       Robustness
b.      Class
c.       Completeness
d.      Verification

Answer: a                          Page Reference:  249                         Difficulty:  Moderate


33.  When drawing a sequence diagram, which of the following is a valid interaction?

a.       Actor with control class
b.      Boundary class with control class
c.       Boundary class with entity class
d.      Actor with entity class

Answer: b                         Page Reference:  250                         Difficulty:  Moderate


34.  The main difference between a communication diagram and a sequence diagram is that a communication diagram:

a.       does not show message passing between objects.
b.      displays attributes of the classes.
c.       is not organized by chronological order of interactions.
d.      shows interactions between objects.

Answer: c                          Page Reference:  251                         Difficulty:  Moderate


35.  The structural aspects of an analysis class diagram can be derived from the:

a.       communication diagram.
b.      sequence diagram.
c.       use case model.
d.      conceptual data model.

Answer: d                         Page Reference:  252                         Difficulty:  Moderate


36.  Transitions, synchronization bars, and decision points are elements of a(n) ____________ diagram.

a.       state
b.      activity
c.       sequence
d.      communication

Answer: b                         Page Reference:  255                         Difficulty:  Moderate


37.  The purpose of synchronization bar is to illustrate:

a.       concurrent processing of activities.
b.      collaborations between objects.
c.       path selection in process flow.
d.      movement from one activity to another.

Answer: a                          Page Reference:  255                         Difficulty:  Moderate


38.  The symbol representing a decision point in an activity diagramis a:

a.       circle.
b.      rectangle.
c.       diamond.
d.      black dot.

Answer: c                          Page Reference:  255                         Difficulty:  Moderate


39.  An object’s ____________ is a situation in which it satisfies a particular condition, performs a particular activity, or waits for a particular event.

a.       process flow
b.      state
c.       synchronization
d.      business rule

Answer: b                         Page Reference:  256                         Difficulty:  Moderate



40.  An action enabler is a type of:

a.       message.
b.      state.
c.       calculation.
d.      business rule.

Answer: d                         Page Reference:  258                         Difficulty:  Moderate


41.  Condition and action stubs are elements of:

a.       activity diagrams.
b.      state transitions.
c.       decision tables.
d.      business rules.

Answer: c                          Page Reference:  260                         Difficulty:  Moderate


42.  Object Constraint Language is used to specify:

a.       business rules.
b.      inheritance relationships.
c.       project cost restrictions.
d.      activity flows.

Answer: a                          Page Reference:  261                         Difficulty:  Moderate


43.  The element for which an OCL expression is defined is called its:

a.       invariant.
b.      context.
c.       derivation.
d.      identifier.

Answer: b                         Page Reference:  262                         Difficulty:  Moderate


Essay and Problem-Solving Questions

44.  Describe the process of developing analysis classes from use cases. List and briefly describe the main steps involved in this process.

Answer:

Given a set of use cases, analysis classes are developed as follows. First, the use cases are analyzed and refined. Then a conceptual data model is developed, and becomes the basis for development of object relations. Next, classes are stereotyped for the system. Specifically, the object relations created from the data model become entity classes, the individual use cases become control classes, and each interaction between an actor and a use case becomes a boundary class. After that, interaction diagrams (sequence and/or communication) are created to indicate the flow of messages between objects. Based on the interaction diagrams, responsibilities for responding to messages are mapped onto the analysis classes, in the form of behavioral method specifications. At this point, the analysis class diagrams can be completed. For complex algorithms, activity and/or state diagrams are drawn to depict object behavior in more detail. Finally, business rules are documented, and decision tables are constructed.

                                          Page Reference:  241                         Difficulty:  Moderate



45.  Define the term “analysis class.” Name and describe three different analysis class stereotypes, and indicate the purpose of each. Also, draw the symbols used for each type of analysis class in UML diagrams. Finally, what are the rules that govern and restrict the interaction between these different kinds of analysis classes in interaction diagrams?

Answer:

An analysis class is a construct that represents initial data and behavioral requirements of a class of objects without respect to hardware or software implementation details.  The three major analysis class stereotypes are entity classes, control classes, and boundary classes. An entity class primarily represents data of the application, and generally corresponds to an object relation in a database. In addition to the attributes of the object relation, an entity class also associates responsibilities, in the form of methods, with each attribute. An entity class is symbolized as a circle lying on top of a horizontal line, as follows:

 




 A control class provides the coordinating behavior of a system, and usually coincides with a use case. Control classes are responsible for representing business rules and policies of the application, and insulate entity classes from concern for these business rules. Control classes are graphically represented as a circle whose outline is a circular arrow, shown below:
 




A boundary class represents the interaction between a system and an actor. Its main purpose is to encapsulate the user interface aspects of an application. A boundary class is represented as a circle with a short line sticking out of it and another short line perpendicular to the first line, shown below:





The rules for interactions between these classes are as follows. Boundary classes can interact directly with actors or with control classes, but not with each other or with entity classes. Control classes can interact with boundary classes, other control classes, or entity classes, but not with actors. Entity classes can interact only with control classes.

                                          Page Reference:  241-243, 250                      Difficulty:  Moderate



46.  What is an interaction diagram? What is the essential information depicted by interaction diagrams? Compare and contrast the two main type of interaction diagrams used in UML. Describe the appearances of the symbols and elements in each diagram, and discuss their relative advantages and disadvantages.

Answer:

An interaction diagram shows the interactions between objects to perform critical pieces of a use case’s behavior. They assist the analyst in distributing responsibilities among classes. In essence, interaction diagrams depict the messages that are passed between objects. The two main types of UML interaction diagrams are the sequence diagram and the communication diagram. A sequence diagram depicts interactions between objects in a time-ordered manner, whereas communication diagrams do not include a time element. In a sequence diagram, objects and actors are distributed horizontally at the top of the diagram, with vertical dotted lines that depict their lifetimes throughout the use case. A thin bar covers the dotted line to represent a time during which the object is active. Labeled arrows point from one bar to the next to show messages being passed between objects. Time is represented from top to bottom; as you move down the chart, you are moving forward in time. Communication diagrams show objects in a network fashion. Arrows point from one object symbol to the other, but unlike the sequence diagram in which an arrow represents a single message being passed, in communication diagrams a single arrow is labeled with all of the messages that pass from one object to the other. Communication diagrams do not spatially represent time sequence spatially; however the order of messages is depicted by applying sequence numbers to the message labels. The advantage of sequence diagrams is the natural representation of time sequences. Communication diagrams are better at providing a summary depiction of collaborations, but do no give as much detail.

                                          Page Reference:  243-248, 251-252   Difficulty:  Moderate



47.  Create a sequence diagram for a use case that assigns employees to projects. The use case uses four object relations: an Employee entity class containing information about employees, a Project entity class containing information about projects the company is working on, and a ProjectAssignment entity class, which keeps track of employee assignments to projects. The user interacts with the system through an online AssignEmployee form, represented by a boundary class. The main algorithm of the use case takes place in an EmployeeAssignment control class. The sequence of events is as follows. First, the user interacts with the AssignEmployee form by requesting information about an employee. The form ,in turn, sends a request to the control class for employee information, and this is sent to the Employee entity class, which returns the information. After receiving the information, the user then requests information about the Project; this request is sent from the form to the control class, and ultimately to the Project entity class, which returns the required information. Finally, the user sends a request to assign the selected employee to the selected project, this request is relayed from the boundary class to the control class and ultimately to the ProjectAssignment entity class.

Answer:

                                          Page Reference:  243-248, 250                      Difficulty:  Hard





48.  What is an activity diagram? What conventional design tool is it similar to? Name and describe each of the elements of an activity diagram, including their meanings and the symbols used to represent them. Discuss the benefits of using activity diagrams, as well as identifying circumstances under which you would want to avoid using activity diagrams.

Answer:

An activity diagram is a UML diagram that shows the flow of control from activity to activity in a system. It serves a similar purpose to the conventional flowchart. Activity diagrams are composed of activities, transitions, decision points, and synchronization bars. An activity is represented as an ellipse and refers to some behavior an object carries out while it is in a particular state. Transitions are the movements between activities, and are represented by arrows. Decision points are represented by diamond shapes, and contain conditions whose responses provide transitions to different paths of activities. Synchronization bars are thick lines denoting concurrent or parallel processing of activities. The beginning synchronization bar is called a fork and the ending synchronization bar is called a join. The starting point of an activity diagram is represented as a small circle, and the termination point is represented with a small circle containing a dot.

Activity diagrams are useful when you want to illustrate a comprehensive flow of action in a system, either at an abstract or detailed level, particularly when you want to show conditional branching and parallel sequences of actions. However, too much reliance of activity diagrams can cause analysis paralysis, and you should not use them for simple use cases, for illustrating collaborations and interactions between objects, or for showing object behavior over an entire lifetime. Instead, they are best used when you want to bring focus to a complex algorithm in a small part of the system.

                                          Page Reference:  253-256                  Difficulty:  Moderate


49.  Create an activity diagram for an order processing object’s behavior. The object begins its order processing functionality by receiving the order from the customer. After the order has been received, the customer will then submit credit card information to the system. At this point a validation test is conducted. If the credit is not valid, then the order is rejected and the process completes. If, however, the credit is valid, then simultaneous messages are sent to both the shipping department and the accounts receivable department regarding the order. After these messages have been sent, the system checks to see if the customer is currently under the preferred customer plan. If so, then bonus points are applied to the customer’s account and the process completes. If not, then the system presents the customer with an option to join the preferred customer plan, and then the process completes.

Answer: (See next page.)




                                          Page Reference:  253-256                  Difficulty:  Hard



50.  Discuss the concept of an object’s state. What does it mean for an object to be in a particular state? Describe how UML state diagrams depict an object’s state transitions, and include descriptions of the symbols used in these diagrams. What is the relationship between statechart diagrams and activity diagrams? Finally, indicate what states are useful for, and when you would want to avoid drawing a statechart diagram.

Answer:

The state of an object is a situation during its lifetime when it satisfies a certain condition, is performing some specific activity, or is waiting for some event. State diagrams depict states as rectangles (or sometimes ellipses) and transitions between states as arrows. The states are labeled, and transitions may or may not also be labeled. The starting point of a state diagram is a circle, and the endpoint is a circle containing a dot. Because some states represent activities, an activity diagram can be considered to be one type of state diagram, in which all states are activities. However, not all state diagrams are activity diagrams, because not all states constitute activities. States are useful for depicting the behavior of an object across multiple use cases. But states are not useful for describing behavior across multiple objects. Furthermore, states should be avoided when an object’s behavior is very simple.

                                          Page Reference:  256-258                  Difficulty:  Moderate


51.  Describe the concept of a business rule and how you can model business rules in analysis classes. Identify four classifications of business rules. For each classification, discuss how they can are implemented and represented.

Answer:

A business rule is a directive intended to guide business behavior in support of policy that is formulated to deal with an opportunity or threat. Business rules can be classified as constraints, calculations, value inferences, and action enablers. Constraints are restrictions on the values of attributes or relationships between objects, and are implemented as data types, domains, validation rules, referential integrity, and multiplicity constraints. Constraints could be mandatory, or could merely be guidelines, and are usually implemented in entity classes or boundary classes. Calculations are algorithms, often using mathematical operations to compute numerical values. These can be the values of derived attributes usually defined in entity classes or more complex algorithms found in control classes. Value inferences are conditional expressions that, when evaluated as true, cause some value to be set in an attribute. Value inferences can be represented in decision tables, decision trees, or structured English. Decision tables consist of a condition stub indicating the conditions being tested for, an action stub indicating the possible actions or values that should result, and a rule indicating which conditions lead to which actions. Another type of inference is an action enabler, whose conditional test causes another business event, message or activity to take place. Action enablers can be implemented in entity classes as triggers, or in control classes.

                                          Page Reference:  258-261                  Difficulty:  Moderate


52.  Create a decision table, with appropriate condition stubs, action stubs, and rules for the following grocery store scanner machine. You should condense the rules whenever possible to account for indifferent conditions.

This scanner will calculate the amount to charge for each product according to the following decision process. There are three considerations that are taken into account. First, the product can be a food item or a non-food item. Second, the customer may or may not have a coupon for the product. Third, the quantity of that product that the customer purchased will have an impact.

The actions to take are as follows. First, regardless of any condition, the product price will be added to the total. If the product is not a food item, the sales tax for the product is added, otherwise there will be no sales tax. If the customer has a coupon for the product, the coupon amount is discounted from the product price. If the product is a food item and the customer has purchased more than five items of that product type, then the bulk rate percentage is applied to the product price. However, in order for the bulk-rate percentage to be applied to a non-food item, the customer must have purchased more than ten of the items of that type.

Answer: (See next page.)




Conditions
Rules
1
2
3
4
5
Product category
--
Food
Non-food
Non-food
--
Coupon?
--
--
--
--
Yes
Quantity purchased
--
>5
>10
--
--
Courses of Action





Apply product price
X




Discount coupon amount




X
Apply bulk-rate

X
X


Add sales tax



X



                                          Page Reference:  260-261                  Difficulty:  Hard



53.  Compare action enablers like triggers with value inferences. What are their similarities and differences? Describe a common tool used to model these business rules, and list different components of this tool.

Answer:

Action enablers such as triggers are statements that conditionally initiate other business events, messages, or activities. These include test conditions that specify the circumstances under which the action should be invoked, events (such as data inserts, updates, or deletes) that trigger the action enabler, event classes on which the action should be taken, actions to take, and a concise statement of the business rule to be enforced. Value inferences are values that get assigned to object attributes based on test conditions. Both value inferences and action enablers perform tests in the form of conditional statements, and follow through with their action or value assignment only if the test succeeds. The difference is, of course, that value inferences result in attribute values whereas action enablers result in actions in the form of method calls. Both action enablers and value inferences can be modeled using decision tables, consisting of condition stubs, action stubs and rules.

                                          Page Reference:  260-262                  Difficulty:  Moderate




1 comment:

  1. Great notes. Do you, by any chance, happen to have notes on Robustness analysis?

    ReplyDelete