Assignment No:-2: Object Oriented Analysis & Design
Assignment No:-2: Object Oriented Analysis & Design
Assignment No:-2: Object Oriented Analysis & Design
CAP-315
Object oriented Analysis
&
Design
Submitted to: Submitted by: Ankur Singh
Course Code:-CAP315
Part A
Q:-1 Differentiate between the terms Generalization and Specialization. Explain with
an example the close association between Generalization and Inheritance.
Ans 1
Generalization
Ankur Singh
specialization means creating new subclasses from an existing class. If it turns out that
certain attributes, associations, or methods only apply to some of the objects of the
class, a subclass can be created. The most inclusive class in a
generalization/specialization is called the superclass and is generally located at the
top of the diagram. The more specific classes are called subclasses and are generally
placed below the superclass.
Ans 2.
A directory may contain many other directories and may optionally be contained in
other directory. Each directory has exactly one user who is the owner and many users
are authorized to use that directory. Respective classes must have their concerned
attributes and operations. Make necessary assumptions, if any.
Ankur Singh
Q:-3 What is association? Differentiate between 1-way and 2-way association
with example for each.
Ans 3
Association defines the relationship between two or more classes in the System. These
generally relates to the one object having instance or reference of another object
inside it. This article discusses on how we can implement Association in UML.
In a one-way association, the first class has a reference to an object of the second class,
Ankur Singh
but the second class does not have a reference to an object of the first class. In a two-
way association, each class contains a reference to an object of the other class.
UML indicates a one-way association with an arrow at the end of the association line.
The attribute in the first class that contains a reference to an object of the second class
is also written at the end of the line.
For example, the following association indicates that an engine is part of a car:
A class can contain more than one association with another class. For example, the
following class diagram shows two associations between classes Flight and Pilot, one
association with the attribute pilot and another with the attribute coPilot:
Q:-4 Write a short note on Structural and Behavioural diagrams. What are the
constituent diagrams of these two broad categories? Discuss in brief, any two
constituent diagrams of each type.
Ans 4
Structural diagrams are the most important and widely used part of UML. If you
say "UML", most people think of structural diagrams first.
Structural diagrams are class diagrams and object diagrams
o Class diagrams represent the object-oriented code in your system. They
define all possible runs of the program.
o Object diagrams give specific examples of one possible run of the program
with specific data.
Class diagrams can be used in requirements to express your understanding of
Ankur Singh
the real-world problem and to define the meaning of words you use in your
proposed solution. These diagrams do not use many of the details of the UML
notation.
In design, class diagrams often have more detail and use more aspects of the
UML notation.
Implementation may still diverge from design by adding more detailed
information. Not every detail of the implementation needs to be shown in the
design, but important aspects should be.
A UML class corresponds to a Java class. A UML Interface corresponds to a Java
Interface. Every operation in an interface must be abstract.
Classes and interfaces are drawn as boxes.
o The box can have up to three compartments
o The top compartment has the name of the class or interface
o Names of interfaces are marked "<<interface>>"
o Names of abstract classes are written in italics
o The lower to compartments are optional and contain attributes and
operations
Each class can have instances when the program is run. The values of variables
in those instances must fit the types defined in the class.
Ankur Singh
FEATURES OF DATA FLOW DIAGRAM
1. All processes must have at least one data flow in and one data flow out.
2. All processes should modify the incoming data, producing new forms of
outgoing data.
3. Each data store must be involved with at least one data flow.
4. Each external entity must be involved with at least one data flow.
5. A data flow must be attached to at least one process.
Multiple Inheritance occurs when a class inherits from more than one parent.
For example, a person is a mammal and an intellectual entity, and a document
may be an editable item and a kind of literature.
Data view: A specialization of the logical view. Use this view if persistence is
a significant aspect of the system, and the translation from the design model
to the data model is not done automatically by the persistence mechanism.
occurs when the maximum of one multiplicity is one and the other is greater
than one. An example is the works in relationship between Employee and
Division. An employee works in one division and any given division has one or
more employees working in it.
Many-to-many relationships. This is a relationship where the maximum of
both multiplicities is greater than one, an example of which is the assigned
relationship between Employee and Task. An employee is assigned one or more
tasks and each task is assigned to zero or more employees.
The second category is based on directionality and it contains two types, uni-
directional relationships and bi-directional relationships.
Part B
Q:-6 Differentiate:
Association is a (*a*) relationship between two classes, where one class use
another. But aggregation describes a special type of an association. Aggregation
is the (*the*) relationship between two classes. When object of one class has an
(*has*) object of another, if second is a part of first (containment relationship)
then we called that there is an aggregation between two classes. Unlike
Ankur Singh
Same way, as another example, you can say that, there is a composite
relationship in-between a KeyValuePairCollection and a KeyValuePair. The two
mutually depend on each other.
.Net and Java uses the Composite relation to define their Collections. I have seen
Composition is being used in many other ways too. However the more important
factor, that most people forget is the life time factor. The life time of the two
classes that has bond with a composite relation mutually depend on each other.
If you take the .net Collection to understand this, there you have the Collection
Element define inside (it is an inner part, hence called it is composed of) the
Collection, farcing the Element to get disposed with the Collection. If not, as an
example, if you define the Collection and it’s Element to be independent, then
the relationship would be more of a type Aggregation, than a Composition. So
the point is, if you want to bind two classes with Composite relation, more
Ankur Singh
accurate way is to have a one define inside the other class (making it a protected
or private class). This way you are allowing the outer class to fulfil its purpose,
while tying the lifetime of the inner class with the outer class.
So in summary, we can say that aggregation is a special kind of an association
and composition is a special kind of an aggregation.
(Association->Aggregation->Composition)
Good Design
Designing software is not the same as creating nice UML diagrams. I know a lot of
programs that have beautiful UML diagrams but are terribly bad designed. On the
other hand, some of the most interesting architectures were not created from an UML
diagram. From a pragmatic perspective, having a good design means that the resulting
architecture provides the basic mechanisms for extending the original program
without the need to rewrite its basic components.
In a well design program, developers can feel confident to extend the system, without
thinking that they need to understand something very subtle about its internals. For
example, very few people need to know how UNIX is internally implemented in order
to write a new application.
Bad Design
A badly designed piece of software can have growing costs that will continue forever
as long as changes are necessary. If there is any need for extension in such a system,
then one has to understand how each piece works together. Working in this way is like
playing with a house of cards: for lack of a foundation, any change in the system can
bring the whole thing down.
Ans 7
Ans 8
Sequence diagrams are used to model the logic of usage scenarios. A usage scenario is
Ankur Singh
exactly what its name indicates -- the description of a potential way your system is
used. The logic of a usage scenario may be part of a use case, perhaps an alternate
course. It may also be one entire pass through a use case, such as the logic described
by the basic course of action or a portion of the basic course of action, plus one or
more alternate scenarios. The logic of a usage scenario may also be a pass through the
logic contained in several use cases. For example, a student enrolls in the university,
and then immediately enrolls in three seminars. Sequence diagrams model the flow of
logic within your system in a visual manner, enabling you to both document and
validate your logic, and are commonly used for both analysis and design purposes.
Q:-9 Create an activity diagram and a use case model (complete with a set of
detail use case descriptions) for the above system. Produce an initial domain
model (class diagram) based on these descriptions. Elaborate the use cases into
sequence diagrams, and include any state diagrams necessary. Finally use the
information from these dynamic models to expand the domain model into a full
application model.
Ans 9
Q:-10 What would be the best UML diagram to show decoupling of two
multithreaded classes, joined by a producer consumer queue.
Ans 10
Ankur Singh
The gap between the speeds of processors and memories has kept increasing in the
past decade and it is expected to sustain the same trend in the near future. This
divergence implies, in terms of clock cycles, an increasing latency of those memory
operations that cross the chip boundaries. In addition, processors keep on growing
their capabilities to exploit parallelism by means of greater issue widths and deeper
pipelines, which makes even higher the negative impact of memory
latencies on performance. To alleviate this problem, most current processors devote a
high fraction of their transistors to on-chip caches, in order to reduce the average
memory access time.
As memory latency continues to grow in the future, out-of-order processors will need
larger instruction windows to find independent instructions to fill the increasing
number of empty issue slots, and this number will grow even faster with greater issue
widths. The increase in the instruction window size will have an obvious influence on
the chip area, but its major negative impact will strike at the processor clock cycle
time
Ankur Singh