Ooad&t Unit-4 Notes
Ooad&t Unit-4 Notes
Ooad&t Unit-4 Notes
1|Page
There are three types of Object Oriented Methodologies:
a. Analysis
b. OMT Models
I. Object Model
II. Dynamic Model
III. Functional Model
c. Design
2|Page
a. Analysis
• The main goal of the analysis is to build models of the world.
• The requirements of the users, developers and managers provide the information needed
to develop the initial problem statement.
b. OMT Models :
I. Object Model :
• It depicts the object classes and their relationships as a class diagram, which represents
the static structure of the system.
• It observes all the objects as static and does not pay any attention to their dynamic nature.
• It captures the behavior of the system over time and the flow control and events in the
Event-Trace Diagrams and State Transition Diagrams.
• It portrays the changes occurring in the states of various objects with the events that might
occur in the system.
c. Design :
• It specifies all of the details needed to describe how the system will be implemented.
• In this phase, the details of the system analysis and system design are implemented.
• The objects identified in the system design phase are designed.
3|Page
2. Object Process Methodology (OPM) :
• It is also called as second generation methodology.
• It was first introduced in 1995.
• It has only one diagram that is the Object Process Diagram (OPD) which is used for
modeling the structure, function and behavior of the system.
• It has a strong emphasis on modeling but has a weaker emphasis on process.
• It consists of three main processes:
I. Initiating: It determines high level requirements, the scope of the system and the
resources that will be required.
II. Developing: It involves the detailed analysis, design and implementation of the system.
III. Deploying: It introduces the system to the user and subsequent maintenance of the
system.
4|Page
Benefits of Object Oriented Methodologies :
4. Simplicity:
The software object's model complexity is reduced and the program structure is very clear.
5. Reusability:
• It contains both data and functions which act on data.
• It makes easy to reuse the code in a new system.
• Messages provide a predefined interface to an object's data and functionality.
6. Increased Quality:
7. Maintainable:
• The objects can be maintained separately, making locating and fixing problems easier.
8. Scalable:
• The object oriented applications are more scalable than structured approach.
9. Modularity:
The OOD systems are easier to modify.
10. Modifiability:
It is easy to make minor changes in the data representation or the procedures in an object
oriented program.
5|Page
II.USE CASE MODEL DEVELOPMENT :
In UML, use-case diagrams model the behavior of a system and help to capture the
requirements of the system. Use-case diagrams describe the high-level functions and
scope of a system. These diagrams also identify the interactions between the system and its
actors.
• Reverse engineering.
• Forward engineering.
A use-case model is a model of how different types of users interact with the system to solve
a problem. As such, it describes the goals of the users, the interactions between the users
and the system, and the required behavior of the system in satisfying these goals.
A use-case model consists of a number of model elements. The most important model
elements are: use cases, actors and the relationships between them.
The use-case model may contain packages that are used to structure the model to simplify
analysis, communications, navigation, development, maintenance and planning.
6|Page
The use-case model serves as a unifying thread throughout system development. It is used
as the primary specification of the functional requirements for the system, as the basis for
analysis and design, as an input to iteration planning, as the basis of defining test cases and
as the basis for user documentation.
1. Actor
2. Use Case
3. Associations
Actor :
A model element representing each actor. Properties include the actors name and brief
description.
Use Case :
A model element representing each use case. Properties include the use case name and use
case specification.
Associations :
Associations are used to describe the relationships between actors and the use cases they
participate in. This relationship is commonly known as a “communicates-association”.
1. Subject
2. Use-Case Package
3. Generalizations
4. Dependencies
7|Page
1. Subject
2. Use-Case Package
A model element used to structure the use case model to simplify analysis, communications,
navigation, and planning. If there are many use cases or actors, you can use use-case
packages to further structure the use-case model in much the same manner you use folders
or directories to structure the information on your hard-disk.
You can partition a use-case model into use-case packages for several reasons, including:
• To reflect the order, configuration, or delivery units in the finished system thus supporting
iteration planning.
• To support parallel development by dividing the problem into bite-sized pieces.
• To simplify communication with different stakeholders by creating packages for
containing use cases and actors relevant to a particular stakeholder.
3. Generalizations
4. Dependencies
A number of dependency types between use cases are defined in UML. In particular,
<<extend>> and <<include>>.
<<extend>> is used to include optional behavior from an extending use case in an extended
use case.
<<include>> is used to include common behavior from an included use case into a base use
case in order to support re-use of common behavior.
8|Page
Example Use-Case Diagram
Figure 1 shows a use-case diagram from an Automated Teller Machine (ATM) use-case
model.
9|Page
III. DOMAIN MODELLING :
A domain model is a visual representation of conceptual classes or real - situation
objects in a domain.
Domain models have also been called conceptual models (the term used in the first
edition of this book), domain object models, and analysis object models.
Applying UML notation, a domain model is illustrated with a set of class diagrams in
which no operations (method signatures) are defined. It provides a conceptual perspective.
lt may show:
10 | P a g e
The objects known throughout domain analysis is classified into 3 types:
1. Boundary objects
2. Controller objects
3. Entity objects
• Boundary objects:
The boundary objects area unit those with that the actors move.
• Entity objects:
These ordinarily hold info like information tables and files that require to outlast use
case execution, e.g. Book, BookRegister, LibraryMember, etc.
• Controller objects:
The controller objects coordinate the activities of a collection of entity objects and
interface with the boundary objects to produce the general behavior of the system.
The controller objects effectively decouple the boundary and entity objects from
each other creating the system tolerant to changes of the computer programme and
process logic.
11 | P a g e
IV. IDENTIFICATION OF ENTITY OBJECTS :
• Entity types
• Attributes
• Relationship types
• Attributes on relationships
Entity Types :
12 | P a g e
An entity type is a set of artifacts with the same structure and independent existence
within the enterprise. Examples of an entity type would be Employees or Products.
Attributes :
The structure of an entity type is defined with attributes. An attribute can be seen
as a property of an entity type. Attributes of an Employee might be Name,
Address, Social Security Number, Birth Date, Date Joined, and Position.
Relationship Types :
While entity types describe independent artifacts, relationship types describe
meaningful associations between entity types. To be precise, the relationship type
describes that entities of entity types participating in the relationship can build a
meaningful association. The actual occurrence of the association between entities
is called a relationship.
13 | P a g e
Booch's Object identification model was used to identify the different objects of
software while doing domain analysis (domain modeling).
It covers the analysis- and design phases of an object-oriented system. ... The
Booch method includes six types of diagrams such as class diagrams, object diagrams,
state transition diagrams, module diagrams, process diagrams and interaction diagrams.
According to Booch's method, a potential object found after the lexical analysis was
The Booch notation is characterized by cloud shapes to represent classes and distinguishes
the following diagrams :
State transition
Dynamic State chart diagram
diagram
1. Macro Process
14 | P a g e
2. Micro process.
1. Macro Process :
2. Micro Process :
The micro process is applied to new classes, structures or behaviors that emerge during the
macro process. It is made of the following cycle:
Retained Information:
The object must contain dome specific and retained information regarding itself. If the
object has no specific information or any sort of private data, then it is not considered to
play an important role in the software. Hence, every valid object must have some
information that could be able to define the object and its usefulness.
Multiple attributes:
15 | P a g e
The multiple attributes in the definition of the object mean that the object supports
multiple methods. The more the number of methods (or attributes), the more the object
Objects with single or very few attributes are usually considered to be a part of other
objects or are directly driven by other objects. Hence, these types of objects are irrelevant
Common operations:
Several common operations are applicable to the potential objects. If all these operations
are applicable to all the occurrences of the object, then they can easily be implemented
to the whole class. If these operations are not applicable to the instances, then the object
is not considered valid because every function of the class must be applicable to every
instance of the class. If such cases hold, then they are considered under special objects
16 | P a g e
In UML models, an interaction is a behavior that represents communication
between one or more participants. A sequence diagram is a UML interaction diagram that
models the messages that pass between participants, such as objects and roles, as well as
the control and conditional structures, such as combined fragments.
The purpose of interaction diagrams is to visualize the interactive behavior of the system.
Visualizing the interaction is a difficult task. Hence, the solution is to use different types of
models to capture the different aspects of the interaction.
Sequence and collaboration diagrams are used to capture the dynamic nature but from a
different angle.
17 | P a g e
Class-responsibility-collaboration (CRC) cards are a brainstorming tool used in the
design of object-oriented software. They were originally proposed by Ward Cunningham and
Kent Beck as a teaching tool, but are also popular among expert designers and
recommended by extreme programming supporters.
Collaboration takes one of two forms: A request for information or a request to do something.
For example, the card Student requests an indication from the card Seminar whether a space
is available, a request for information.
So how do you create CRC models? Iteratively perform the following steps:
• Find classes.
• Find responsibilities
• Define collaborators.
• Move the cards around.
18 | P a g e
VIII. APPLICATIONS OF THE ANALYSIS AND DESIGN
PROCESS :
UML is a graphical language for visualizing, specifying, constructing, and documenting
information about software-intensive systems. UML gives a standard way to write a system
model, covering conceptual ideas. With an understanding of modeling, the use and
application of UML can make the software development process more efficient.
The following lists of UML diagrams and functionality summaries enable understanding of
UML applications in real-world examples.
Structuring diagrams show a view of a system that shows the structure of the objects,
including their classifiers, relationships, attributes and operations:
• Class diagram
• Component diagram
• Composite structure diagram
• Deployment diagram
• Object diagram
• Package diagram
• Profile diagram
19 | P a g e
Behaviour diagrams and their applications :
Behaviour diagrams are used to illustrate the behavior of a system, they are used extensively
to describe the functionality of software systems.
• Activity diagram
• State machine diagram
• Use case diagram
Interaction diagrams are subset of behaviour diagrams and emphasize the flow of control and
data among the things in the system being modelled:
• Communication diagram
• Interaction overview diagram
• Sequence diagram
• Timing diagram
20 | P a g e
IX. OBJECT –ORIENTED DESIGN PRINCIPLES :
The Principles are :
1. Single Responsibility Principle (SRP)
2. Open-Closed Principle (OCP)
3. Liskov Substitution Principle (LSP)
4. Interface Segregation Principle (ISP)
5. Dependency Inversion Principle (DIP)
The ISP requires that clients should not be forced to depend on interfaces that they do not
use.
5. Dependency Inversion Principle (DIP) :The DIP requires that high level modules should
not depend on low level modules, both should depend on abstraction. Also, abstraction
should not depend on details, details should depend on abstractions.
21 | P a g e
Characteristics of Good Object Oriented Design
1. Coupling guidelines
2. Cohesion guideline
3. Hierarchy and factoring guidelines
4. Keeping message protocols simple
5. Number of Methods
6. Depth of the inheritance tree
7. Number of messages per use case
8. Response for a class
1.Coupling guidelines:
The number of messages between 2 objects or among a gaggle of objects ought to be
minimum. Excessive coupling between objects is decided to standard style and prevents
reuse.
2. Cohesion guideline:
In OOD, cohesion is regarding 3 levels:
A. Cohesiveness of the individual methods
B. Cohesiveness of the data and methods within a class
C. Cohesiveness of an entire class hierarchy
A. Cohesiveness of the individual methods:
The cohesiveness of every of the individual technique is fascinating since it
assumes that every technique will solely a well-defined perform.
B. Cohesiveness of the data and methods within a class:
This is fascinating since it assures that the ways of associate object do actions that
the thing is, of course, accountable, i.e. it assures that no action has been
improperly mapped to associate object.
C. Cohesiveness of an entire class hierarchy:
The cohesiveness of ways among a category is fascinating since it promotes
encapsulation of the objects.
22 | P a g e
3. Hierarchy and factoring guidelines:
A base category mustn’t have too several subclasses. If too several subclasses area unit
derived from one base category, then it becomes troublesome to grasp the planning. In
fact, there ought to about be no quite 7±2 categories derived from a base category at any
level.
4.Keeping message protocols simple:
Complex message protocols area unit a sign of excessive coupling among objects. If a
message needs quite three parameters, then it’s a sign of dangerous style.
5.Number of Methods:
Objects with an outsized range of ways area unit possible to be additional application-
specific and conjointly troublesome to understand – limiting the likelihood of their employ.
Therefore, objects mustn’t have too several ways. this can be alive of the quality of a
category. it is possible that the categories having quite regarding seven ways would have
issues.
6.Depth of the inheritance tree:
The deeper a category is within the class inheritance hierarchy, the bigger is that the
range of ways it’s possible to inherit, creating it additionally advanced. Therefore, the peak
of the inheritance tree mustn’t be terribly giant.
7.Number of messages per use case:
If ways of an outsized range of objects area unit invoked in a very chain action in
response to one message, testing and debugging of the objects becomes difficult.
Therefore, one message mustn’t end in excessive message generation and transmission
in a very system.
8.Response for a class:
This is a life of the most range of ways that associate instance of this category would
decision. If an identical technique is termed quite once, then it’s counted just the once. a
category that calls quite regarding seven totally different ways is liable to errors.
23 | P a g e
XI. CK Metrics / Chidamber & Kemerer object-oriented metrics
suite :
The CK metrics suite consists of six metrics: Weighted Methods Per Class (WMC),
Depth of Inheritance Tree (DIT), Number of Children (NOC), Cou- pling between Object
Classes (CBO), Response For a Class (RFC), and Lack of Cohesion in Methods (LCOM).
The CK metrics can be used to measure some characteristics of OO systems
such as classes, message passing, inheritance, and encapsulation. ... Therefore, it is
necessary to develop new metrics for software maintainers to better understand the
complexity of classes as well as the potential effects of changing classes.
The Chidamber & Kemerer metrics suite originally consists of 6 metrics calculated for
each class:
1. Weight Methods Per Class (WMC)
2. Depth of Inheritance Tree (DIT)
3. Number of Children (NOC)
4. Coupling between Object Classes (CBO)
5. Response for a Class (RFC)
6. Lack of Cohesion of Methods (LCOM1)
Despite its long name, WMC is simply the method count for a class.
WMC is a predictor of how much time and effort is required to develop and maintain the class.
DIT = maximum inheritance path from the class to the root class
24 | P a g e
NOC = number of immediate sub-classes of a class
NOC equals the number of immediate child classes derived from a base class.
NOC measures the breadth of a class hierarchy, where maximum DIT measures the
depth. Depth is generally better than breadth, since it promotes reuse of methods through
inheritance. NOC and DIT are closely related. Inheritance levels can be added to increase
the depth and reduce the breadth.
Two classes are coupled when methods declared in one class use methods or instance
variables defined by the other class. The uses relationship can go either way: both uses and
used-by relationships are taken into account, but only once.
Multiple accesses to the same class are counted as one access. Only method calls and
variable references are counted. Other types of reference, such as use of constants, calls to
API declares, handling of events, use of user-defined types, and object instantiations are
ignored. If a method call is polymorphic (either because of Overrides or Overloads), all the
classes to which the call can go are included in the coupled count.
25 | P a g e
The response set of a class is a set of methods that can potentially be executed in response
to a message received by an object of that class. RFC is simply the number of methods in
the set.
A given method is counted only once in R (and R’) even if it is executed by several
methods M.
Since RFC specifically includes methods called from outside the class, it is also a
measure of the potential communication between the class and other classes.
A large RFC has been found to indicate more faults. Classes with a high RFC are more
complex and harder to understand. Testing and debugging is complicated. A worst case value
for possible responses will assist in appropriate allocation of testing time.
The 6th metric in the Chidamber & Kemerer metrics suite is LCOM (or LOCOM), the lack
of cohesion of methods. This metric has received a great deal of critique and several
alternatives have been developed.
XII. LK METRICS :
Lorenze and Kidd proposed the following OO metrics.There are 4 metrics :
26 | P a g e
Metric 1: Class Size metric (CS)
Metric 2: Number of Operations (methods) Overridden by a subclass (NOO)
There are instances when a subclass replaces a method, inherited from its super class with
a specialized version, for its own use. This type of replacement is called overriding. A large
value of NOO generally indicates a design complexity problem, which makes a class difficult
to test and modify.
Subclasses are specialized by adding methods and attributes. When the value of NOA
increases, the subclass drifts away from the abstraction implied by the super class. This
indicates a low quality of design .
XIII.MOOD METRICS :
27 | P a g e
The MOOD metrics consist of the following software quality indicators: Attribute
Hiding Factor (AHF), Method Hiding Factor (MHF), Method Inheritance Factor (MIF),
Attribute Inheritance Factor (AIF), Coupling Factor (COF), and Polymorphism Factor (POF).
The MOOD metric set is used to measure the properties of the system in which the
design of the system is according to the concepts of Object-Oriented Design that is
Encapsulation, Coupling, Inheritance, Information Hiding, Polymorphism.
28 | P a g e
The set contains six main metrics to measure the design of the system.
To measure how the attributes and methods of one class are encapsulated, Method and
Attribute hiding factors are being used. MHF and AHF show the average amount of how the
members of a class are hidden in the system.
C = Number of classes
In Inheritance, the child or subclass inherits the properties (Attribute and Methods) of
the parent or superclass. The extent to which these methods and attributes are inherited is
defined by Method Inheritance Factor(MIF) and Attribute Inheritance Factor(AIF).
A child class that inherits a large number of methods and attributes from its parent
class contains a large value of MIF and AIF.
29 | P a g e
To measure the degree or extent of method overriding by the child class form the parent
or superclass, Polymorphism Factor (PF) is used.
In polymorphism, the child class can implement the method in a different way. The same
method can be implemented in different ways in the child and parent class.
It is defined by the ratio of an actual number of method overrides and the maximum number
of total method overrides. To keep the code clean and clear and provide high quality we can
use high PF but it increases the complexity of the system.
Polymorphism factor is associated with method overriding, it is not associated with method
overloading.
If two or more clauses are related to each other by means of inheritance or aggregation
or association then, in that case, these classes are said to be coupled.
Many functionalities of the system can be done with the help of coupled classes. It is
not advisable to have too many independent classes. The high value of Cf shows that the
classes of the system are more inter-connected and inter-dependent.
To measure the actual coupling between different classes Coupling Factor (CF) is
used. It is the ratio of Actual coupling between different classes and maximum possible
coupling can happen in the system. If a class can access the method and attributes of the
second class then it is said that the first class is coupled with the second class.
MOOD2 METRICS :
To enhance the original MOOD metrics, the MOOD2 metrics set was later added. The
new suite provides the original six metrics along with that it provides new metrics - OHEF,
AHEF, IIT, PPF.
30 | P a g e
1. Operation Hiding Effectiveness Factor(OHEF) and Attribute Hiding Effectiveness
Factor(AHEF) :
OHEF and AHEF are better and improved versions of MHF and AHF. MHF measures
the level of method hiding in the system whereas OHEF measures how good the hiding is
and how well it is successfully implemented. It measures the goodness of the scope of the
operation of the method of the class.
OHEF = Classes that do access operations / Classes that can access Operations
AHEF = Classes that do access attributes / Classes that can access attributes
AHF measures the level of attribute hiding in the system whereas AHEF measures
how the attributes are hiding and how successful the attribute hiding is. These two factors are
used widely for the system that imposed the object-oriented paradigm.
31 | P a g e
particular behavior-preserving transformation, such as “Extract Method” or “Introduce
Parameter.”
Refactoring is the process of restructuring code, while not changing its original
functionality. The goal of refactoring is to improve internal code by making many small
changes without altering the code's external behavior.
Computer programmers and software developers refactor code to improve the design,
structure and implementation of software. Refactoring improves code readability and reduces
complexities. Refactoring can also help software developers find bugs or
vulnerabilities hidden in their software.
The refactoring process features many small changes to a program's source code.
One approach to refactoring, for example, is to improve the structure of source code at one
point and then extend the same changes systematically to all applicable references
throughout the program. The thought process is that all the small, behavior-preserving
changes to a body of code have a cumulative effect. These changes preserve the software's
original behavior and do not modify its behavior.
• Easier for software developers to find and fix bugs or vulnerabilities in the code.
32 | P a g e
If it is not, then the developer can refactor the existing code. Once the new code is added,
the developer can refactor the same code again to make it clearer.
• Makes the code easier to understand and read because the goal is to simplify code
and reduce complexities.
• Improves maintainability and makes it easier to spot bugs or make further changes.
• Focus remains only on functionality. Not changing the code's original functionality
ensures the original project does not lose scope.
• Red, green. This widely used refactoring method in Agile development involves three
steps. First, the developers determine what needs to be developed; second, they get
their project to pass testing; and third, they refactor that code to make improvements.
• Moving features between objects. This technique creates new classes, while
moving functionality between new and old data classes.
• Extract. This technique breaks down code into smaller pieces and then moves those
pieces to a different method. Fragmented code is replaced with a call to the new
method.
33 | P a g e
• Refactoring by abstraction. This technique reduces the amount of duplicate code.
This is done when there is a large amount of code to be refactored.
• Plan for refactoring. It may be difficult to make time for the time-consuming practice
otherwise.
• Refactor first. Developers should do this before adding updates or new features to
existing code to reduce technical debt.
• Refactor in small steps. This gives developers feedback early in the process so they
can find possible bugs, as well as include business requests.
• Set clear objectives. Developers should determine the project scope and goals early
in the code refactoring process. This helps to avoid delays and extra work, as
refactoring is meant to be a form of housekeeping, not an opportunity to changes
functions or features.
• Test often. This helps to ensure refactored changes do not introduce new bugs.
• Automate wherever possible. Automation tools make refactoring easier and faster,
thus, improving efficiency.
• Fix software defects separately. Refactoring is not meant to address software flaws.
Troubleshooting and debugging should be done separately.
• Understand the code. Review the code to understand its processes, methods,
objects, variables and other elements.
• Refactor, patch and update regularly. Refactoring generates the most return on
investment when it can address a significant issue without taking too much time and
effort.
34 | P a g e
• Focus on code deduplication. Duplication adds complexities to code, expanding the
software's footprint and wasting system resources.
35 | P a g e