Unit3 Mandeep
Unit3 Mandeep
Unit: III
Object Oriented Programming
Mandeep Singh
B Tech 6th Semester Assistant Professor
CSE Department
1
Faculty Information
Faculty Information
• E-Mail: [email protected]
3
Course Objective
4
Course Outcome
5
Program Outcome
6
6. The engineer and society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member
or leader in diverse teams, and in multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with
the engineering community and with the society at large, such as, being able to
comprehend and write effective reports and design documentation, make effective
presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of
the engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multidisciplinary
environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
7
CO-PO Mapping
CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
2 2 2 1 2 2 - - - - - 2 2 2
CO1
2 2 3 1 2 2 - - - - - 2 2 2
CO2
2 2 2 1 2 1 1 - - - - 2 2 2
CO3
2 2 2 1 2 - 1 - - - - 2 2 2
CO4
2 2 3 1 2 - - - - - - 2 2 2
CO5
2 2 2.4 1 2 1.6 1 - - - - 2 2 2
CO
8
Brief Introduction about the Subject with Videos
Videos: https://www.youtube.com/watch?v=LpU2h-4iEys
https://www.youtube.com/watch?v=hozM7JhFFXg
9
Prerequisites and Revision
In the Unit-1 students learnt the basic functionality and basic concepts of object
oriented design techniques and UML modelling.
In Unit-2, the students will understand the Structural model: a view of an system,
that emphasizes the structure of the objects, including their classifiers,
relationships, attributes and operations and the structural relationships.
In Unit-3, the students will understand the concept of object oriented design and
object oriented programming style: models, algorithms, concept of SA/SD, JSD
10
Object oriented design
11
Object oriented design
Object Identification
• The first step of object design is object identification. The objects identified in
the object–oriented analysis phases are grouped into classes and refined so
that they are suitable for actual implementation.
• The func ons of this stage are − Identifying and refining the classes in each
subsystem or package Defining the links and associations between the
classes Designing the hierarchical associations among the classes, i.e., the
generalization/specialization and inheritances Designing aggregations.
Object Representation:
• Once the classes are identified, they need to be represented using object
modeling techniques. This stage essentially involves constructing UML
diagrams. There are two types of design models that need to be produced −
• Static Models − To describe the static structure of a system using class
diagrams and object diagrams.
• Dynamic Models − To describe the dynamic structure of a system and show the
interaction between classes using interaction diagrams and state–chart
diagrams
12
Classification of Operations
Classification of Operations:
• In this step, the operation to be performed on objects are defined by
combining the three models developed in the OOA phase, namely, object
model, dynamic model, and functional model. An operation specifies what
is to be done and not how it should be done.
• The following tasks are performed regarding operations −
• The state transition diagram of each object in the system is developed.
• Operations are defined for the events received by the objects.
• Cases in which one event triggers other events in same or different objects
are identified.
• The sub–operations within the actions are identified. The main actions
are expanded to data flow diagrams.
13
Algorithm Design
Algorithm Design:
• The operations in the objects are defined using algorithms. An algorithm
is a stepwise procedure that solves the problem laid down in an
operation. Algorithms focus on how it is to be done. There may be more
than one algorithm corresponding to a given operation. Once the
alternative algorithms are identified, the optimal algorithm is selected for
the given problem domain. The metrics for choosing the optimal
algorithm are −
• Computa onal Complexity − Complexity determines the efficiency of an
algorithm in terms of computation time and memory requirements.
• Flexibility − Flexibility determines whether the chosen algorithm can be
implemented suitably, without loss of appropriateness in various
environments
• Understandability − This determines whether the chosen algorithm is easy
to understand and implement.
14
Design of Relationships
Design of Relationships
• The strategy to implement the relationships needs to be chalked out during
the object design phase. The main relationships that are addressed comprise
of associations, aggregations, and inheritances.
• The designer should do the following regarding associations −
• Identify whether an association is unidirectional or bidirectional.
• Analyze the path of associations and update them if necessary.
• Implement the associations as a distinct object, in case of many–to-many
relationships; or as a link to other object in case of one–to-one or one–to
many relationships.
• Regarding inheritances, the designer should do the following −
• Adjust the classes and their associations.
• Identify abstract classes.
• Make provisions so that behaviors are shared when needed.
15
Implementation of Control
• The object designer may incorporate refinements in the strategy of the state–chart
model. In system design, a basic strategy for realizing the dynamic model is made.
During object design, this strategy is aptly embellished for appropriate
implementation.
• The approaches for implementation of the dynamic model are −
• Represent State as a Location within a Program − This is the traditional procedure-
driven approach whereby the location of control defines the program state. A finite
state machine can be implemented as a program. A transition forms an input
statement, the main control path forms the sequence of instructions, the branches
form the conditions, and the backward paths form the loops or iterations.
• State Machine Engine − This approach directly represents a state machine through
a state machine engine class. This class executes the state machine through a set of
transitions and actions provided by the application
• Control as Concurrent Tasks − In this approach, an object is implemented as a task
in the programming language or the operating system. Here, an event is
implemented as an inter-task call. It preserves inherent concurrency of real objects.
16
Packaging Classes
• In any large project, meticulous partitioning of an implementation into modules or
packages is important. During object design, classes and objects are grouped into
packages to enable multiple groups to work cooperatively on a project.
• The different aspects of packaging are −
• Hiding Internal Information from Outside View − It allows a class to be viewed as a
“black box” and permits class implementation to be changed without requiring any
clients of the class to modify code.
• Coherence of Elements − An element, such as a class, an opera on, or a module, is
coherent if it is organized on a consistent plan and all its parts are intrinsically
related so that they serve a common goal.
• Construction of Physical Modules − The following guidelines help while
construc ng physical modules −
• Classes in a module should represent similar things or components in the same
composite object. Closely connected classes should be in the same module.
Unconnected or weakly connected classes should be placed in separate modules.
Modules should have good cohesion, i.e., high cooperation among its components.
A module should have low coupling with other modules, i.e., interaction or
interdependence between modules should be minimum.
17
Design Optimization
• The analysis model captures the logical information about the system, while the
design model adds details to support efficient information access. Before a
design is implemented, it should be optimized so as to make the implementation
more efficient. The aim of optimization is to minimize the cost in terms of time,
space, and other metrics.
• However, design optimization should not be excess, as ease of implementation,
maintainability, and extensibility are also important concerns. It is often seen
that a perfectly optimized design is more efficient but less readable and
reusable. So the designer must strike a balance between the two.
• The various things that may be done for design optimization are −
• Add redundant associations
• Omit non-usable associations
• Optimization of algorithms
• Save derived attributes to avoid re-computation of complex expressions
18
Design Documentation
19
Implementation of control
20
Structured Analysis and Structured Design (SA/SD)
21
Basic Structural
Structured Analysis Modeling(CO2)
and Structured Design (SA/SD)
Structured Analysis
• DFDs consists of Processes, data flows, actors, and data stores
• Data dictionary contains details missing from DFDs
• State transition diagrams models time dependent behavior similar to dynamic
models. State diagrams defines the timings of function Execution and data access
triggered by the events
• ER diagrams are based on object modeling.
22
Basic Structural
Structured Analysis Modeling(CO2)
and Structured Design (SA/SD)
Structured Design
• Structured design follows structured analysis and addresses low level details
• During structure design DFDs are grouped into task and allocated to operating system
processes and CPU
• Data flow diagrams processes are converted into programming language functions and
structure chart is created
SA/SD is combined known as SAD and it mainly focuses on the following 3 points:
1. System
2. Process
3. Technology
23
SA/SD PHASES
1. Analysis Phase :
• Analysis Phase involves data flow diagram, data dictionary, state transition diagram,
• In the data flow diagram, the model describes how the data flows through the system.
• We can incorporate the Boolean operators and & or link data flow when more than
operator or and if two data flows are necessary for a process we can add an operator.
The input of the process “check-order” needs the credit information and order
credit-order 24
Basic
SA/SDStructural
PHASES Modeling(CO2)
• It is similar to the dynamic model. It specifies how much time the function will take
• It also describes all of the states that an object can have, the events under which an
object changes state, the conditions that must be fulfilled before the transition will
occur and the activities were undertaken during the life of an object.
25
Basic
SA/SDStructural
PHASES Modeling(CO2)
3. Data dictionary
• The content that is not described in the DFD is described in the data
• A physical data dictionary for data elements that flow between processes,
• This would also include descriptions of data elements that flow external to
• A logical data dictionary may also be included for each such data element.
All system names, whether they are names of entities, types, relations,
26
Basic
SA/SDStructural
PHASES Modeling(CO2)
4. Design Phase
• Design Phase involves structure chart and pseudocode.
1. Structure Chart:
• It is created by the data flow diagram. Structure Chart specifies how DFS’s
processes are grouped into tasks and allocate to the CPU.
• The structured chart does not show the working and internal structure of
the processes or modules and does not show the relationship between data
or data-flows. Similar to other SASD tools, it is time and cost-independent
and there is no error-checking technique associated with this tool.
• The modules of a structured chart are arranged arbitrarily and any process
from a DFD can be chosen as the central transform depending on the
analysts’ own perception. The structured chart is difficult to amend, verify,
maintain, and check for completeness and consistency.
27
Basic
SA/SDStructural
PHASES Modeling(CO2)
Pseudo Code:
28
Basic
SA/SDStructural
PHASES Modeling(CO2)
We May use following guidelines for selecting the most appropriate tool that would
suit your requirements −
⮚ Use DFD at high or low level analysis for providing good system
documentations.
⮚ Use data dictionary to simplify the structure for meeting the data requirement of
the system.
⮚ Use structured English if there are many loops and actions are complex.
⮚ Use decision tables when there are a large number of conditions to check and
logic is complex.
⮚ Use decision trees when sequencing of conditions is important and if there are
few conditions to be tested.
29
Jackson Structured Development (JSD)
• JSD does not distinguish between analysis and design instead lumps both
phases together as specification.
• JSD divides system development into two stages specification then
implementation.
• JSD first determines what and the How.
• JSD is intended specially for applications in which timing is important.
• JSD is less graphically oriented than SA/SD and OMT.
• Jackson Structured Development (JSD) is a method of system development
that covers the software life cycle either directly or by providing a
framework into which more specialized techniques can fit.
• JSD can start from the stage in a project when there is only a general
statement of requirements. However many projects that have used JSD
actually started slightly later in the life cycle, doing the first steps largely
from existing documents rather than directly with the users.
30
Phases Of Jackson System Development (JSD)
Modelling Phase:
In the modelling phase of JSD, the designer creates a collection of entity
structure diagrams and identifies the entities in the system, the actions they
perform, the attributes of the actions and the time order of the actions in the
life of the entities.
Specification Phase: This phase focuses on actually what is to be done?
Previous phase provides the basic for this phase. An sufficient model of a
time-ordered world must itself be time-ordered. Major goal is to map progress
in the real world on progress in the system that models it.
31
JSD Steps:
Initially there were six steps when it was originally presented by Jackson, they
were as below:
1. Entity/Action step
2. Initial Model step
3. Interactive Function step
4. Information Function step
5. System Timing step
6. System Implementation step
Later some steps were combined to create method with only three steps:
1. Modelling Step
2. Network Step
3. Implementation Step
32
During Entity action step the software developer lists entities and actions for the part
of real world
Example : Jackson Elevator control System
• The Elevator control system controls two elevators Which service six floors.
Each elevator has six inside buttons one for each floor. Each floor has up and down
buttons in the waiting area.
Jackson identifies two entities for the elevator control
a. Button
b. Elevator
He identifies three actions
a. Press a button
b. Elevator arrives at floor n
c. Elevator leaves floor n
33
The Entity structure step Partially orders the action of each entity by time .
the elevator control system illustrate the importance of ordering actions
.it is permissible for an elevator to arrive at floor 3 leaving floor 3 , arrive at floor
2, leave floor 2 and so on. It does not make sense for two arrived actions to occur
in succession; arrive and leave operations must be alternate.
The Initial Model step states how the real world connects to the abstract
model.JSD supports state vector and data stream connection
The elevator user does not want the control system to remember each button
pressed and send an elevator fine to service request .the JSD model of the
computer system is unaware of the number of presses and only communicates
with the real world in the “up-flag.
Function step: It uses pseudo code to state output of actions. At the end of this
step the developer has a complete specification of the required system in the
elevator example, turning the display panel lights on or off as an elevator arrives
at each floor is a function that must be specified.
34
System timing step: this step considers how much the model is
permitted to lag the real world. For the most part, the result of the
timing step is a set of informal notes on performance constraints. For
example an elevator control system must detect when up and down
buttons are pressed.
35
Merits of JSD
36
Demerits of JSD:
37
Video Links and Reference
• https://www.youtube.com/watch?v=-DP1i2ZU9gk
• https://nptel.ac.in/courses/106105224/
• https://nptel.ac.in/noc/courses/noc21/SEM2/noc21-cs57/
• James Rumbaugh et. al, “Object Oriented Modeling and Design”, PHI
• Grady Booch, James Rumbaugh, Ivar Jacobson, “The Unified Modeling
Language User Guide”, Pearson Education
• Object Oriented Programming With C++, E Balagurusamy, TMH
• C++ Programming, Black Book, Steven Holzner, dreamtech
• Object Oriented Programming in Turbo C++, Robert Lafore, Galgotia
• Object Oriented Programming with ANSI and Turbo C++, Ashok Kamthane,
Pearson
• The Complete Reference C++, Herbert Schlitz, TMH
38
Thank
You.
39