Sunteți pe pagina 1din 26

Session 1

Instructor Inputs
1.2 Instructor Inputs NIIT
Session Overview
This session covers Chapter 1.

Prerequisite Knowledge for the Session


To understand the concepts covered in the session, the students should be aware of the
following concepts/skills:
 Creating flowcharts and write pseudocode
 Working in Windows environment

Tips for Handling the Session


This session introduces the object-oriented concepts to the students. You need to relate
these concepts to real-life examples. Encourage the students to come up with examples of
things around them. Use the slides Programming_Using C++_Session_01.pps to conduct
the session.

Note: Each session covers one chapter. The footer in the slide contains Lesson 1, which is
same as Session 1.

Slide 1

Introduction to Object-Oriented Approach

Objectives
In this lesson, you will learn to:
Explain the features of object-oriented methodology
Describe the phases of object-oriented methodology
Create classes in C++

©NIIT OOPS/Lesson 1/Slide 1 of 34

Start the session by sharing the session objectives with the students.

NIIT Instructor Inputs 1.3


Slide 2

Introduction to Object-Oriented Approach

Complexity of the Software System


 Internal Complexity
 Arises from the composition of a system itself
 External Complexity
 Arises from the fact that users themselves have
only a vague idea of how their system works and
have difficulty in expressing their requirements

©NIIT OOPS/Lesson 1/Slide 2 of 34

Explain the types of complexities involved in a software system. Provide the students with
real life examples so that they can understand easily understand the concepts.

Slide 3

Introduction to Object-Oriented Approach

Reasons for the Complexity Involved in the


Development of Software
 Difficulty in managing the software development
process
 Lack of standards for developing software
 Difficulty in predicting software behavior

©NIIT OOPS/Lesson 1/Slide 3 of 34

Explain the reasons for the difficulties involved in the Development of Software by taking
appropriate examples.

1.4 Instructor Inputs NIIT


Slide 4

Introduction to Object-Oriented Approach

Simplifying Complexity
 Is done by breaking the system into its component
parts and arranging them in a hierarchy

©NIIT OOPS/Lesson 1/Slide 4 of 34

Ask the students how they could simplify the complexities involved in a software system.
Elaborate upon the correct answers provided by the students. Also explain how the
breaking of the system into its component parts and arranging them in a hierarchy helps in
reducing the complexity.

NIIT Instructor Inputs 1.5


Slide 5

Introduction to Object-Oriented Approach

Just a Minute…
Jane has called a technician to repair her television. How
would the technician deal with the complexity of the
television?

©NIIT OOPS/Lesson 1/Slide 5 of 34

Use this slide for a quick recap of the concepts. The solution for the preceding problem is:
The television is a complex system. It would be impossible and thus meaningless to
understand its comprehensive functioning, at one go. Thus, the technician would
concentrate on the different parts of a television and understand their respective functions
and the problems that are likely to occur in each one of them. For example, the technician
might first inspect if the antenna for the television is positioned appropriately. Then, he
might inspect the picture tube of the television.

1.6 Instructor Inputs NIIT


Slide 6

Introduction to Object-Oriented Approach

Object
 Is an instance of a class that exhibits some well-
defined behavior

©NIIT OOPS/Lesson 1/Slide 6 of 34

Explain objects and its use to the students.

Slide 7

Introduction to Object-Oriented Approach

Characteristics of Objects
 State
 Is indicated by a set of attributes and the values of
these attributes
 Behavior
 Is indicated by how an object acts and reacts
 Identity
 Distinguishes the object from all other objects

©NIIT OOPS/Lesson 1/Slide 7 of 34

Use this slide to explain the characteristics of an object. Provide the students with the
example of an object, such as a music system. If the music system is at ideal position, it

NIIT Instructor Inputs 1.7


depicts the state of that object. If the music system starts playing music, it depicts
behavior. The model number of the music system depicts its identity.

Ask the students to state some more examples of objects by depicting their state, behavior,
and identity.

Slide 8

Introduction to Object-Oriented Approach

Just a Minute…
Identify the possible attributes to define the state of the
following objects:
 Tea cup
 Stereo tape-recorder

©NIIT OOPS/Lesson 1/Slide 8 of 34

Use this slide for a quick recap of the concepts. The solution for the preceding problem is:

Attributes of a teacup: the dimension, the material with which the cup is made, and the
color(s) used in the cup.

1.8 Instructor Inputs NIIT


Slide 9

Introduction to Object-Oriented Approach

Classes
 Define the attributes and behaviors of an object
 Example:

B IR D S

PEAC O C K SPAR R O W K IN G F IS H E R

©NIIT OOPS/Lesson 1/Slide 9 of 34

Introduce the concept of the class and explain it by providing a real-world example.
Explain the concept of class and objects by using the example given in the slide. You can
also state the example of the furniture class, which has objects such as a table, a chair, and
a desk.

At this time, tell the students that all things can be classified as living and nonliving.
These can then be classified as classes and then they can identify the objects of these
classes.

Ask the students to give examples of classes and objects.

NIIT Instructor Inputs 1.9


Slide 10

Introduction to Object-Oriented Approach

Messages and Methods


Messages:
 Are transmitted by one object to another
 Are transmitted as requests for an action to be taken
 Are accompanied by additional information needed to
carry out the request

©NIIT OOPS/Lesson 1/Slide 10 of 34

Slide 11

Introduction to Object-Oriented Approach

Messages and Methods (Contd.)


Methods:
 Are a set of actions taken by the receiver object in
response to the request

©NIIT OOPS/Lesson 1/Slide 11 of 34

Use slides 10 and 11 for explaining the concept of messages and methods.

1.10 Instructor Inputs NIIT


Slide 12

Introduction to Object-Oriented Approach

Just a Minute…
Dr. James and Mr. Hyde went to the railway station to
book two tickets in the Flying express for 3 rd December
by AC 1st class. Identify the following:
a.The possible receiver of the message in this situation
b.The possible method that the receiver can use

©NIIT OOPS/Lesson 1/Slide 12 of 34

Use this slide for a quick recap of the concepts. The solution for the preceding problem is:
1. The receiver of the message here would be the clerk sitting behind the counter.
2. The clerk would check if two tickets are available on the train in the desired class,
on the desired date. If they are, the clerk would enter the details (either he would put
down the details of name, age, date, seat, berth numbers, etc, in a register or feed it
in the computer) confirming the reservation of two tickets, and collect the fare.

NIIT Instructor Inputs 1.11


Slide 13

Introduction to Object-Oriented Approach

Benefits of the Object-Oriented Approach


 Realistic modeling
 Easy to use
 Reusability
 Saves time and cost

©NIIT OOPS/Lesson 1/Slide 13 of 34

Use this slide to explain the benefits of object-oriented approach. You can use the car
class example to explain that realistic modeling in the object-oriented approach helps
identify objects along with their attributes and behavior. Explain the attributes and the
behavior of the car class. Ford Fusion is an object that belongs to the car class. The Ford
Fusion has attributes such as engine, color, model, and mileage. It displays behavior such
as running on a road, halting while running on a road, and honking.

Now, explain the concept of reusability by extending the car class example. A company
wants to make a new car with a new feature. It wants to use the design of an existing car
model and add the new functionality to it. Therefore, the company is reusing the design.

1.12 Instructor Inputs NIIT


Slide 14

Introduction to Object-Oriented Approach

Just a Minute…
State whether the following situations demonstrate
reusability:
a. Recycling paper
b. Pump reusability (same pump is used in a well and in
a fuel station)

©NIIT OOPS/Lesson 1/Slide 14 of 34

Use this slide for a quick recap of the concepts. The solution for the preceding problem is:
1. Does not represent reusability because the paper is destroyed before new paper is
made. Hence, the old paper loses its identity and cannot be considered the same as
the new paper. Consumption is not reusability.
2. Represents reusability because a pump can be used for suction of water as well as
petrol. Here, it is not the same pump, but the mechanism (method) is being reused.

NIIT Instructor Inputs 1.13


Slide 15

Introduction to Object-Oriented Approach

Benefits of Object-Oriented Approach (Contd.)


 Resilience to change
 Easy to maintain
 Parts of the system can be refined without any
major change in other parts

©NIIT OOPS/Lesson 1/Slide 15 of 34

Explain the concept of resilience to change. Discuss the example of a car manufacturing
company that wants to run one of its existing car models on CNG. This is an example of
resilience.

1.14 Instructor Inputs NIIT


Slide 16

Introduction to Object-Oriented Approach

Object-Oriented Analysis (OOA)


Analysis:
 Is a phase where users and developers get together
and arrive at a common understanding of the system
 Requires the developer to concentrate on obtaining
maximum possible information about the problem
domain
 Results in one of the end products as specification of
the function of the system

©NIIT OOPS/Lesson 1/Slide 16 of 34

Use slides 16, 17, and 18 to explain various phases of software development. You can
give an example of a builder who needs to construct a shopping mall. In the analysis
phase, the builder identifies the requirements of the project, which includes the
requirement for raw materials, money, labour, etc.

In the design phase, the builder creates a prototype or a model of the shopping mall and
gets it approved from the client. The construction of the shopping mall starts in the
implementation phase.

You can use the board in the classroom to explain the various phases. Ask the students to
relate these phases to the phases in software development.

Tell the students that the analysis phase of a software development project involves
understanding the user requirements. The design phase involves creating a prototype of
the software application on the basis of the user requirements. The implementation phase
involves developing and deploying the software application at the user end.

NIIT Instructor Inputs 1.15


Slide 17

Introduction to Object-Oriented Approach

Object-Oriented Design (OOD)


Design:
 Generates the blueprint of the system that has to be
implemented
 Involves identifying classes using
 Abbott’s technique

©NIIT OOPS/Lesson 1/Slide 17 of 34

Slide 18

Introduction to Object-Oriented Approach

Object-Oriented Design (OOD) (Contd.)


 Abbott’s technique follows the listed steps:
 Write English description of the problem
 Underline nouns (nouns represent candidate
classes)

©NIIT OOPS/Lesson 1/Slide 18 of 34

1.16 Instructor Inputs NIIT


Slide 19

Introduction to Object-Oriented Approach

Object-Oriented Programming (OOP)


 Is a way of writing programs
 Some applications built using OOP techniques are:
 Computer-Aided Design (CAD)
 Computer-Aided Manufacturing (CAM)
 Artificial Intelligence (AI) and Expert Systems
 Object-Oriented Databases

©NIIT OOPS/Lesson 1/Slide 19 of 34

Explain the Object-Oriented programming. Also, mention the advantages of using


Object-Oriented programming.

Slide 20

Introduction to Object-Oriented Approach

Just a Minute…
As a member of a team that is developing the billing
system software for Diaz Telecommunications Inc., you
have been assigned the task of creating a software
module that accepts and displays customer details.
Identify the class that you will create and the methods of
the class.

©NIIT OOPS/Lesson 1/Slide 20 of 34

NIIT Instructor Inputs 1.17


Use this slide for a quick recap of the concepts. The solution for the preceding problem is:

As per the problem statement, the class required is:


 Customer

As per the problem statement, the class should have the following methods:
 Method to accept customer details
 Method to display customer details on the screen

Slide 21

Introduction to Object-Oriented Approach

Generations of Computer Languages


 First generation
 Second generation
 Third generation

©NIIT OOPS/Lesson 1/Slide 21 of 34

Use this slide to discuss the brief history of the languages. Tell the students about the
generation of languages. Also, discuss the advantages and limitations of the languages
that fall under different generations of languages.

1.18 Instructor Inputs NIIT


Slide 22

Introduction to Object-Oriented Approach

Evolution of C++ as an Object Oriented


Programming Language
 In the early 1980s, Bjarne Stroustrup developed the
C++ language
 C++ was originally known as 'C with classes'

©NIIT OOPS/Lesson 1/Slide 22 of 34

Introduce C++ to students. Discuss the brief history of the evolution of C++.

Slide 23

Introduction to Object-Oriented Approach

Creating Classes in C++


Sample:
class Car
{
public:
void honk()
{
cout<<"BEEP BEEP!";
}
};

©NIIT OOPS/Lesson 1/Slide 23 of 34

Use slides 23, and 24 to discuss the how to create classes in C++. Explain the example
given in the slides.

NIIT Instructor Inputs 1.19


Slide 24

Introduction to Object-Oriented Approach

Creating Classes in C++ (Contd.)


 The class keyword
 Is used to declare a class
Example:
class Car
{
...

};

©NIIT OOPS/Lesson 1/Slide 24 of 34

Slide 25

Introduction to Object-Oriented Approach

Creating Classes in C++ (Contd.)


 Conventions for naming classes
 Should be meaningful
 Should ideally be a noun
 First letter of every word should be in upper case
 Rules for naming classes
 Must not contain any embedded space or symbol
 Must begin with a letter, which may be followed by
a sequence of letters or digits
 Cannot be a keyword

©NIIT OOPS/Lesson 1/Slide 25 of 34

Use this slide to discuss the conventions and rules that should be followed to name the
classes.

1.20 Instructor Inputs NIIT


Slide 26

Introduction to Object-Oriented Approach

Creating Classes in C++ (Contd.)


 Member functions
 Are means of passing messages and responding
to them
 Are declared inside the class body
Example:
class Car
{ void honk()
{ cout<<"BEEP BEEP!";
}
};

©NIIT OOPS/Lesson 1/Slide 26 of 34

Use this and the next slide to discuss member functions. Also, explain the keywords used
in the example that is given in the slide.

Slide 27

Introduction to Object-Oriented Approach

Creating Classes in C++ (Contd.)


 The cout object
 Is an instance of the pre-defined class, ostream
 The endl manipulator
 Is a command that takes the cursor to the new line

©NIIT OOPS/Lesson 1/Slide 27 of 34

NIIT Instructor Inputs 1.21


Slide 28

Introduction to Object-Oriented Approach

Problem Statement 1.D.1


As a member of a team that is developing the billing
system software for Diaz Telecommunications Inc., you
have been assigned the task of creating a software
module that accepts and displays customer details.
Declare the Customer class and the member functions.
The member function to accept customer details should
display the message “Accepting Customer Details”.
Similarly, the member function to display customer
details on the screen should display the message
“Displaying Customer Details.”

©NIIT OOPS/Lesson 1/Slide 28 of 34

Use this slide to conduct the activity in the collaborative mode.

You can divide the class into various groups. Ask each group to provide a solution to the
problem statement. The group that solves the problem statement first will present its
solution to the class.

1.22 Instructor Inputs NIIT


Slide 29

Introduction to Object-Oriented Approach

Problem Statement 1.D.1 (Contd.)


Solution:
class Customer
{
void accept()
{
cout << “Accepting Customer Details” <<
endl;
}
void display()
{
cout << “Displaying Customer Details” <<
endl;
}
};

©NIIT OOPS/Lesson 1/Slide 29 of 34

Use this slide to discuss the solution with the students.

Slide 30

Introduction to Object-Oriented Approach

Problem Statement 1.P.1


As a member of a team that is developing an automated
booking system for the Railways, you have been
assigned the task of creating a module that accepts the
details of a passenger and checks whether the ticket has
been confirmed or is in the waiting list. The module then
prints the list of confirmed passengers. Declare a class
Ticket, which consists of three member functions,
booking(), status(), and print().

©NIIT OOPS/Lesson 1/Slide 30 of 34

Use this slide to conduct the activity in the collaborative mode by dividing the class into
various groups. Ask each group to provide a solution to the problem statement. The group
that solves the problem statement first will present its solution to the class.

NIIT Instructor Inputs 1.23


At the end of the class, you can provide the solution to the students. You can find the
solution in the TIRM CD at the following path.

DATAFILES FOR FACULTY\Programming Using C++\1.P.1\1P1.cc

Slide 31

Introduction to Object-Oriented Approach

Summary
In this lesson, you learned that:
 Complexity of software arises mainly due to four
reasons:
 Difficulty in understanding the intricacies and
complexity of the system and its needs
 Communication problems during development
 Lack of standards for developing software
 Difficulty in predicting software behavior
 One way of dealing with the complexity of software is
to break down an application into its components and
deal with each component separately
©NIIT OOPS/Lesson 1/Slide 31 of 34

Use this and the next three slides to summarize the session.

Slide 32

Introduction to Object-Oriented Approach

Summary (Contd.)
 The object-oriented approach views the systems as
consisting of component objects and looks at the
interactions between them
 An object is an entity that may have a physical
boundary and is also characterized by the following:
 State
 Behavior
 Identity
 A class consists of a set of objects that share a
common structure and behavior
 If one object desires an action from another object, it
sends a message to the second object
©NIIT OOPS/Lesson 1/Slide 32 of 34

1.24 Instructor Inputs NIIT


Slide 33

Introduction to Object-Oriented Approach

Summary (Contd.)
 The object that receives the message is called the
receiver; the set of actions taken by the receiver
constitutes the method
 The benefits of the object-oriented approach are:
 Realistic modelling, hence it is easier to use
 Reusability of code, hence it saves time and cost
 Resilience to change, hence systems are easier to
maintain
 In the stages of analysis and design, a model of the
system is built

©NIIT OOPS/Lesson 1/Slide 33 of 34

Slide 34

Introduction to Object-Oriented Approach

Summary (Contd.)
 The purpose of the model built during analysis and
design is to help developers understand the reality
that they are trying to imitate
 Bjarne Stroustrup developed the C++ language in the
early 1980s
 The cout object is an instance of the class, ostream
 The class ostream is associated with the standard
output device (screen)
 The output operator '<<' is used to direct a value to
the standard output device

©NIIT OOPS/Lesson 1/Slide 34 of 34

NIIT Instructor Inputs 1.25


FAQs
The following questions can be asked by the student in the session:

Where is the cout object defined?

Ans. In the header file, iostream.h.

What is the difference between C and C++?

Ans. There are many differences, but the most important ones are as follows:
 The C language does not have the concept of a class.
 C structures cannot have member functions or private members.

C does not allow variables to be defined any-where in the code other than the beginning
of a block.

Why are we not learning C in this semester?

Ans. C++ is used more than C nowadays. C++ is more versatile and can be used for a
larger number of applications than C. C++ is a superset of C.

Can a C++ program run on a Windows platform?

Ans. Yes. A Windows specific compiler like the Visual C++ and DJGPP GUI compiler
will compile C++ programs and allow it to run on Windows.

Do we need to know C before learning C++?

Ans. No. This course teaches C++ from the ground up.

1.26 Instructor Inputs NIIT

S-ar putea să vă placă și