SE-3311 Object Oriented Analysis & Design Solved Past Paper-2019

University of Sargodha

M.Sc. 3rd Term Examination 2019.

Subject: I.T                Paper: Object Oriented Analysis and Design(SE-3311)

Time Allowed: 2:30 Hours                                                                                              Maximum Marks: 80

Note: Objective Part is Compulsory. Attempt any three questions from subjective part.

Objective Part                     (Compulsory)

Q.1.     Write short answers of the following in 2-3 lines each on your answer sheet    

i.     Explains the UML’s Structural diagrams?

ANSWER: UML Structural diagrams depict the elements of a system that are independent of time and that convey the concepts of a system and how they relate to each other. The elements in these diagrams resemble the nouns in a natural language, and the relationships that connect them are structural or semantic relationships.

ii.     Contrast between simple aggregation & Composition Aggregation?

ANSWER:

Aggregation

Composition

In aggregation there exhibit a relationship where a child can exist independently of the parent.

In composition the cannot exist independently of the parent.

Aggregation is a weak association

Composition is a strong association

Represented by a hollow diamond next to assembly class.

Represented by a solid diamond next to assembly class.

The deletion of assembly doesn’t affect its parts.

If the owning class object is deleted, it could significantly affect the containing class object.

iii.     What are the common uses of use case Diagram?

ANSWER:

  1. Used to gather the requirements of a system.
  2. Used to get an outside view of a system.
  3. Identify the external and internal factors influencing the system.
  4. Show the interaction among the requirements are actors.

iv.     What is domain model and what it represents?

ANSWER: The domain model is used to decompose the domain into concepts or objects in the real world. The model should identify the set of conceptual classes. It is the basis for the design of the software.

v.     Give meaning to event, state & transition?

ANSWER:

vi.     List the relationships used in the class diagram?

ANSWER:

  1. Association
    1. Directed Association
    2. Reflexive Association
  2. Multiplicity
  3. Aggregation
  4. Composition
  5. Inheritance/Generalization

vii.     What is Elaboration?

ANSWER: The purpose of the Elaboration Phase is to analyze the problem domain, establish a sound architectural foundation, develop the project plan, and eliminate the highest risk elements of the project.

viii.     Define components with example?

ANSWER: A component is an identifiable part of a larger program or construction. Usually, a component provides a particular function or group of related functions. In programming design, a system is divided into components that in turn are made up of modules. For  Example User management module in any software.

ix.     What is the use of UML package diagram?

ANSWER: Package diagram is a structural diagram. Package diagrams are used to show the arrangement and organization of model elements in middle to large scale project. Package diagram can show both structure and dependencies between sub-systems or modules, showing different views of a system.

x.     Differentiate between the traditional and object-oriented views of software.

ANSWER: Traditional Software focuses on modeling processes or actions that manipulate data and can separate the data from process. Object-oriented development models a system as a collection of objects that combine processes and data. Object-oriented modeling is based on the concepts of class and inheritance.

xi.      What is the use of system sequence diagram?

ANSWER: A system sequence diagram is a type of sequence diagram in UML. These diagrams show the details of events that are generated by actors from outside the system.

xii.     What is interaction diagram? Mention the types of interaction diagrams?

ANSWER: An interaction diagram is a type of UML diagram that’s used to capture the interactive behavior of a system. Interaction diagrams focus on describing the flow of messages within a system, providing context for one or more lifelines within a system. Interaction Diagrams includes Communication Diagrams, Sequence Diagrams, Timing Diagrams and Interaction overview Diagrams.

xiii.     State how analysis is different from design?

ANSWER:

Analysis emphasizes an investigation of the problem and requirements, rather than a solution. For example, if a new online trading system is desired, how will it be used? What are its functions?

Design emphasizes a conceptual solution (in software and hardware) that fulfills the requirements, rather than its implementation. For example, a description of a database schema and software objects.

xiv.     What is an instance, give examples?

ANSWER: Instance is a realization of anything in real world. In OOD an instance is a concrete occurrence of any Entity.

xv.     What is deployment Diagram?

ANSWER: A deployment diagram shows how artifacts are deployed on system hardware, and how the pieces of hardware connect to one another. The main hardware item is a node, a generic name for a computing resource.

xvi.     Discuss the use of fork and join with respect to activity diagram?

ANSWER:

Fork node is a control node that has one incoming edge and multiple outgoing edges and is used to split incoming flow into multiple concurrent flows. Fork nodes are introduced to support parallelism in activities.

Join node is a control node that has multiple incoming edges and one outgoing edge and is used to synchronize incoming concurrent flows. Join nodes are introduced to support parallelism in activities.

 

Question 04: (a) Draw a state transition diagram of above scenario

ANSER

(b) Explain the state machine diagram and its components using scenario of telephone line.

State machine diagram

A state machine is any device that stores the status of an object at a given time and can change status or cause other actions based on the input it receives. States refer to the different combinations of information that an object can hold, not how the object behaves.

A UML state machine diagram illustrates the interesting events and states of an object, and the behavior of an object in reaction to an event. Transitions are shown as arrows, labeled with their event. States are shown in rounded rectangles.

Each state diagram typically begins with a dark circle that indicates the initial state and ends with a bordered circle that denotes the final state. However, despite having clear start and end points, state diagrams are not necessarily the best tool for capturing an overall progression of events. Rather, they illustrate specific kinds of behavior—in particular, shifts from one state to another.

State diagrams mainly depict states and transitions. States are represented with rectangles with rounded corners that are labeled with the name of the state. Transitions are marked with arrows that flow from one state to another, showing how the states change.

Components of State machine Diagram:

1.    State:

A state is the condition of an object at a moment in time the time between events. A rectangle with rounded corners is used to indicate the current state of the object.

For example: A telephone is in the state of being “idle” after the receiver is placed on the hook and until it is taken off the hook.

2.    Transition:

A transition is a relationship between two states that indicates that when an event occurs, the object moves from the prior state to the subsequent state. An arrow running from one state to another is used to indicate a changing state.

For example: When the event “off hook” occurs, transition the telephone from the “idle” to “active” state.

3.    Event:

An event is a significant or noteworthy occurrence. An instance that triggers a transition, labeled above the applicable transition arrow.

For example: A telephone receiver is taken off the hook.

Question 05: a) Write short note on Information Expert, Creator, Controller and observer Pattern.

ANSWER:

Patterns:

In Object Oriented design, a pattern is a named description of a problem and solution that can be applied in new contexts; ideally, a pattern advises us on how to apply its solution in varying circumstances and considers the forces and trade-offs. Many patterns, given a specific category of problem, guide the assignment of responsibilities to objects.

Information Expert

Problem: What is a basic principle by which to assign responsibilities to objects?

Solution: Assign responsibility to the class that has the information needed to fulfill it.

Information expert (also expert or the expert principle) is a principle used to determine where to delegate responsibilities such as methods, computed fields, and so on.

Using the principle of information expert, a general approach to assigning responsibilities is to look at a given responsibility, determine the information needed to fulfill it, and then determine where that information is stored.

Creator:

The Creator design pattern provides a way to create objects of any generalized or concrete type, where the concrete type and the initialization of the created object is chosen by any arbitrary dynamic or static context and the client which invokes the creation has no dependency to the creating object (the factory) or its generalizations. The factory implements the instantiation and further initialization of the object to create, but is never called (directly) by the client itself. If the client invokes the creation of an object for a generalized type, then the client will have no knowledge about and no dependency to the concrete type of that object, which the factory uses to create that object.

Controller:

The controller pattern assigns the responsibility of dealing with system events to a non-UI class that represents the overall system or a use case scenario. A controller object is a non-user interface object responsible for receiving or handling a system event.

Controller Deals with how to delegate the request from the UI layer objects to domain layer objects. When a request comes from UI layer object, Controller pattern helps us in determining what is that first object that receives the message from the UI layer objects. This object is called controller object which receives request from UI layer object and then controls/coordinates with other object of the domain layer to fulfill the request. It delegates the work to other class and coordinates the overall activity.

Observer Pattern.

Observer pattern is used when there is one-to-many relationship between objects such as if one object is modified, its dependent objects are to be notified automatically. Observer pattern falls under behavioral pattern category.

Observer pattern uses three actor classes. Subject, Observer and Client. Subject is an object having methods to attach and detach observers to a client object. We have created an abstract class Observer and a concrete class Subject that is extending class Observer.

b) What are different components of Activity diagram? Give an example.

Activity Diagram:

An activity diagram is a pictorial representation of a series of actions or flow of control in a system. It is almost similar to a flowchart or a data flow diagram. Activities modeled can be sequential and concurrent. In both cases an activity diagram will have a beginning (an initial state) and an end (a final state).

       1.      Activity State

      Activity state is a step in the activity wherein the users or software perform a given task. Activities states are symbolized with round-edged rectangles.

       2.      Control Flow:

      Control flows or Action flows, also called edges and paths, represents the transitions from one action state to another. They are usually drawn with an arrowed line.

       3.      Initial Node:

       Initial Node is the starting point of the activity. It is denoted by a small filled circle followed by an arrow.

      4.      Final Node:

      Final node represents the final step in the activity, where the activity ends. The end node is represented by an outlined black circle.

      5.      Decision Node:

      A Decision node represents a decision point in the activity on the basis of some condition. It is denoted by a diamond symbol. A decision node must have a single input and two output flows. 

      6.      Merge Node:

       A merge Node combines together multiple flows that are not concurrent. Its main purpose is to merge multiple flows into a single flow. It may have multiple inputs and a single output flow.

      7.      Fork Node:

      Fork node is used for branching of flows in two or more parallel flows we use a synchronization bar, which is depicted as a thick horizontal or vertical line.

      8.      Join Node:

      Join node is a control node that has multiple incoming edges and one outgoing edge and is used to synchronize incoming concurrent flows. Join nodes are introduced to support parallelism in activities.

Question 06: Explain the GOF Patterns.

What are Design Patterns?

Design patterns provide solutions to common software design problems. In the case of Object Oriented Programming, design patterns are generally aimed at solving the problems of object generation and interaction, rather than the larger scale problems of overall software architecture. They give generalized solutions in the form of templates that may be applied to real-world problems.

Design patterns are a powerful tool for software developers. However, they should not be seen as prescriptive specifications for software. It is more important to understand the concepts that design patterns describe, rather than memorizing their exact classes, methods and properties. It is also important to apply patterns appropriately. Using the incorrect pattern for a situation or applying a design pattern to a trivial solution can over complicate your code and lead to maintainability issues.

Who is the Gang of Four?

The Gang of Four are the authors of the book, “Design Patterns: Elements of Reusable Object-Oriented Software”. This important book describes various development techniques and pitfalls in addition to providing twenty-three object-oriented programming design patterns. The four authors were Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides.

Gang of Four Design Patterns

There are twenty three design patterns discussed by Gang of Four. These patterns are discussed below.

Creational Patterns

The first type of design pattern is the creational pattern. Creational patterns provide ways to instantiate single objects or groups of related objects. There are five such patterns:

i.            Abstract Factory. The abstract factory pattern is used to provide a client with a set of related or dependent objects. The “family” of objects created by the factory is determined at run-time.

ii.            Builder. The builder pattern is used to create complex objects with constituent parts that must be created in the same order or using a specific algorithm. An external class controls the construction algorithm.

iii.            Factory Method. The factory pattern is used to replace class constructors, abstracting the process of object generation so that the type of the object instantiated can be determined at run-time.

iv.            Prototype. The prototype pattern is used to instantiate a new object by copying all of the properties of an existing object, creating an independent clone. This practice is particularly useful when the construction of a new object is inefficient.

v.            Singleton. The singleton pattern ensures that only one object of a particular class is ever created. All further references to objects of the singleton class refer to the same underlying instance.

Structural Patterns

The second type of design pattern is the structural pattern. Structural patterns provide a manner to define relationships between classes or objects.

vi.            Adapter. The adapter pattern is used to provide a link between two otherwise incompatible types by wrapping the “adaptee” with a class that supports the interface required by the client.

vii.            Bridge. The bridge pattern is used to separate the abstract elements of a class from the implementation details, providing the means to replace the implementation details without modifying the abstraction.

viii.            Composite. The composite pattern is used to create hierarchical, recursive tree structures of related objects where any element of the structure may be accessed and utilized in a standard manner.

ix.            Decorator. The decorator pattern is used to extend or alter the functionality of objects at run-time by wrapping them in an object of a decorator class. This provides a flexible alternative to using inheritance to modify behavior.

x.            Facade. The facade pattern is used to define a simplified interface to a more complex subsystem.

xi.            Flyweight. The flyweight pattern is used to reduce the memory and resource usage for complex models containing many hundreds, thousands or hundreds of thousands of similar objects.

xii.            Proxy. The proxy pattern is used to provide a surrogate or placeholder object, which references an underlying object. The proxy provides the same public interface as the underlying subject class, adding a level of indirection by accepting requests from a client object and passing these to the real subject object as necessary.

Behavioral Patterns

The final type of design pattern is the behavioral pattern. Behavioral patterns define manners of communication between classes and objects.

xiii.       Chain of Responsibility. The chain of responsibility pattern is used to process varied requests, each of which may be dealt with by a different handler.

xiv.       Command. The command pattern is used to express a request, including the call to be made and all of its required parameters, in a command object. The command may then be executed immediately or held for later use.

xv.       Interpreter. The interpreter pattern is used to define the grammar for instructions that form part of a language or notation, whilst allowing the grammar to be easily extended.

xvi.       Iterator. The iterator pattern is used to provide a standard interface for traversing a collection of items in an aggregate object without the need to understand its underlying structure.

xvii.       Mediator. The mediator pattern is used to reduce coupling between classes that communicate with each other. Instead of classes communicating directly, and thus requiring knowledge of their implementation, the classes send messages via a mediator object.

xviii.       Memento. The memento pattern is used to capture the current state of an object and store it in such a manner that it can be restored at a later time without breaking the rules of encapsulation.

xix.       Observer. The observer pattern is used to allow an object to publish changes to its state. Other objects subscribe to be immediately notified of any changes.

xx.       State. The state pattern is used to alter the behavior of an object as its internal state changes. The pattern allows the class for an object to apparently change at run-time.

xxi.       Strategy. The strategy pattern is used to create an interchangeable family of algorithms from which the required process is chosen at run-time.

xxii.       Template Method. The template method pattern is used to define the basic steps of an algorithm and allow the implementation of the individual steps to be changed.

xxiii.       Visitor. The visitor pattern is used to separate a relatively complex set of structured data classes from the functionality that may be performed upon the data that they hold.