SOLVED QUESTIONS

UNIT 2:

ADVANCED CLASS MODELING, STATE MODELING:

1.Explain the different properties of an association end? (6m) [June 2013]

Associations ends

Association End is an end of association.

A binary association has 2 ends; a ternary association has 3 ends

Association end names Multiplicity implicitly refers to the ends of associations. For E.g. A one-to-many association has two ends –

•an end with a multiplicity of “one”

•an end with a multiplicity of “many”

•Ordering is an inherent part of association. You can indicate an ordered set of objects by writing “{ordered}” next to the appropriate association end.

Fig: ordering sometimes occurs for “many” multiplicity

Bags and Sequences

•Normally, a binary association has at most one link for a pair of objects.

•However, you can permit multiple links for a pair of objects by annotating an association end with {bag} or {sequence}.

•A bag is a collection of elements with duplicates allowed.

•A sequence is an ordered collection of elements with duplicates allowed.

Multiplicity

Multiplicity is a collection on the cardinality of a set, also applied to attributes (database application).

Multiplicity of an attribute specifies the number of possible values for each instantiation of an attribute. i.e., whether an attribute is mandatory ([1]) or an optional value ([0...1] or * i.e., null value for database attributes) .

Multiplicity also indicates whether an attribute is single valued or can be a collection.

Visibility

Visibility refers to the ability of a method to reference a feature from another class and has the possible values of public, protected, private, and package.

Any method can access public features.

Only methods of the containing class and its descendants via inheritance can access protectedfeatures.

Only methods of the containing class can access private features.

Methods of classes defined in the same package as the target class can access package features

2.Explain the several kinds of events with an example. (6m)[ June 2014]

Events

An event is an occurrence at a point in time, such as user depresses left button or Air Deccan flight departs from Bombay.

An event happens instantaneously with regard to time scale of an application.

One event may logically precede or follow another, or the two events may be unrelated (concurrent; they have no effect on each other).

Events include error conditions as well as normal conditions.

Three types of events:

•signal event,

•change event,

•Time event.

Signal Event

  • A signal is an explicit one-way transmission of information from one object to another.
  • It is different form a subroutine call that returns a value.

  • An object sending a signal to another object may expect a reply, but the reply is a separate signal under the control of the second object, which may or may not choose to send it.

<signal>
DigitDialed / <signal>
MouseButton Pushed
digit / Button location
  • A signal event is the event of sending or receiving a signal (concern about receipt of a signal).
  • Eg:

<signal> StringEnter
text

The difference between signal and signal event

a signal is a message between objects a signal event is an occurrence in time.

Change Event

  • A change event is an event that is caused by the satisfaction of a Boolean expression.
  • UML notation for a change event is keyword when followed by a parenthesized Boolean expression.

Eg:

when (room temperature < heating set point )
  • when (room temperature > cooling set point )
  • when (battery power < lower limit )
  • when (tire pressure < minimum pressure )

Time Event

  • Time event is an event caused by the occurrence of an absolute time or the elapse of a time interval.
  • UML notation for an absolute time is the keyword when followed by a parenthesized expression involving time.
  • The notation for a time interval is the keyword after followed by a parenthesized expression that evaluates to a time duration.

Eg:

  • when (date = jan 1, 2000 )
  • after (10 seconds )

3.List and explain the various restructuring techniques used with respect to workarounds(10 M) [Jan 2013]

Sol: restructuring techniques w.r.t workaround:

•Delegation using composition of parts

•Inherit tree most important class and delegate the rest

•Nested generalization

•Super classes of equal importance dominant super class

•Few subclasses

•Sequencing generalization sets large quantities of code identity

•Describing any four of above with example.

•For Description see notes

4.What is a constraint with respect to a class modeling? Explain.

i)Constraints on generalization sets

ii)Constraints on links. (10 M)[ [Jan 2013]

Sol:

Generalization is the relationship between a class (the super class) and one or more variations of the class (the subclasses). Generalization organizes classes by their similarities and differences, structuring the description of objects.

The super class holds common attributes, operations and associations;

the subclasses add specific attributes, operations and associations.

Each subclass is said to inherit the features of its super class.

Multiplicity is a constraint on links, multiplicity of an attribute specifies the number of possible values for each instantiation of an attribute. i.e., whether an attribute is mandatory ([1]) or an optional value ([0...1] or * i.e., null value for database attributes)

5. Draw state diagram for telephone line with activities. (10m)[June 2015]

Sol: