2. Part (1): Objects:
• Objects and classes.
• Deriving and object-oriented design.
Part (2): Functional oriented design:
• Data flow diagrams.
• Structure charts.
• Data dictionaries.
• Deriving structure charts.
• Design examples.
• Concurrent systems design.
Part (3): User interface design:
• User interface design objectives.
• Interface metaphors.
Course Contents
3. Course description
Course name and code Credit
hours
Weekly credit hours
(WCH)
Semester
work
Final
exam
Total
Lectures Tutorial
Object oriented
programming (CS-315A)
3 3 2 60 90 150
4. A Look at How We See the World.
Objects.
Abstract Objects and Instances.
Classes and structures.
Objects and classes.
Methods.
Lecture Outlines
5. A Look at How We See the World
How do you see the world?
Molecular structures
Scientist
Artist
Programmer
Shapes and Colors
Data required to
emulates the real world
6. A Look at How We See the World
What is meant by stuff?
Stuff is anything you have and anything you want.
A house is stuff.
Things you have in your house are stuff.
Things you throw away are stuff.
The things you want to buy.
A house is made up of other stuff, such as windows and doors.
• The term stuff is less technical that you expect in a course on
object-oriented programming, but it does give you a reference
point to begin learning object-oriented programming.
7. A Look at How We See the World.
Objects.
Abstract Objects and Instances.
Classes and structures.
Objects and classes.
Methods.
Lecture Outlines
8. Objects
What is meant by Object?
Stuff is an object.
A house is an object.
The things you have in your house are objects.
Things your throw away are objects.
Things you want to buy are objects.
All of us, regardless of our background, view the world as
objects.
An object is a person, place, thing, concept, or possibly event.
9. How to learn about Objects?
Each of us is considered an object in the world of object-oriented
programming. We call this object a person.
A person is described by using two groups of features:
Attributes
First name
Last name
Height
Weight
Behaviors
Sits
Stands
Walks
Runs
Objects
10. How to learn about Objects?
Another example of objects is an automobile, airplane, and even a
sales order form are objects. Attributes and behaviors of an
automobile and airplane can be described as follows:
Attributes
Width
Height.
Weight.
Wheels dimensions.
Engine specs.
many other attributes.
Behaviors
Move in a direction.
Stop.
Steered to a different
direction.
Can perform many other
actions.
Objects
11. A Look at How We See the World.
Objects.
Abstract Objects and Instances.
Classes and structures.
Objects and classes.
Methods.
Lecture Outlines
12. What are abstract objects and instances?
programmers view an object in two ways (abstract object-real object).
The term abstract object is a description of a real object minus details.
Real objects
First Name.
Last Name.
Height.
Weight.
Abstract Objects
Bob.
Smith.
6 feet tall.
160 pounds.
• Programmers create an abstract object and then use the abstract
object to create a real object. A real object is called an instance of
the abstract object. You can say that a real person is an instance of
the abstract person (cookie cutter is a good example).
Abstract Objects and Instances
13. Why we need to define Objects?
Focusing on objects makes it easy for us to understand complex things.
Objects enable us to look at details that are of interest to us and ignore
other details that we are not interested in.
• For example, a teacher is a person and has many of the attributes
and behaviors. you probably ignore many of the teacher’s attributes
and behaviors and focus on only those that relate to your education.
• Likewise, the teacher focuses on your attributes and behaviors that
indicate how well you are learning material in class.
• Both you and your teacher simplify your relationship by deciding
attributes and behaviors that are important to each of your
objectives and then use only those attributes and behaviors in your
relationship.
Abstract Objects and Instances
14. A Look at How We See the World.
Objects.
Abstract Objects and Instances.
Classes and structures.
Objects and classes.
Methods.
Lecture Outlines
15. What is the difference between Classes and Structures?
Class: it provides flexibility in combining data and methods and it
provides re-usability (inheritance)
Structure: It provides data grouping.
To understand the difference between classes and structures we
should know the difference between heap and stack memories.
Classes and structures
Class Structure
• All members are private by default • All members are public by default
• Allow to perform clean-up (garbage collector)
as it work on heap memory
• Structures cannot allow garbage collector so
no efficient memory management
• Size of empty class = 1 Byte • Size of empty structure = 0 Byte
• Classes fits for larger and complex objects • Structures are good for small and isolated
model objects.
16. What is the difference between Heap and Stack
memories?
Heap and Stack memories
Heap Stack
• Reference type: created on heap
memory
• Value type: Created on stack memory
• Memory is accessible by all functions • To create a new function we have to
create a new stack
• Used when we don’t know the
amount of memory used
• Used when we know exactly the
amount of memory used
• Use pointers • Don’t require pointers
• Variable allocation is low • Variable allocation is fast
• Dynamic memory location • Static memory location
• Unlimited size • Limited size
• Variables can be re-sized • Variables cannot be re-sized
17. A Look at How We See the World.
Objects.
Abstract Objects and Instances.
Classes and structures.
Objects and classes.
Methods.
Lecture Outlines
18. What is the relation between Objects and Classes in OOP?
Objects: a piece of code that represents real life entity (they are an instance of a
Class).
Class: it contains one or more objects.
• Class is a structure where we can define variables and methods to utilize
objects.
• Without Class, Objects doesn’t exist.
• Without Objects we commonly use static function of Class.
A Person has saving bank account
Objects and Classes
Class student
{
ID no;
Name;
Grades;
GPA;
};
Collection of Objects
Object Class
19. What are the characteristics of a class?
• It is an extensible program-code-template for creating objects.
• A class provides initial values for state member variables and
implementation of behavior.
• In many languages, the class name is used as the name for the
class.
• When an object is created by a constructor of the class, the
resulting object is called an instance of the class, and the member
variables specific to the object are called instance variables, to
contrast with the class variables shared across the class.
Objects and Classes
20. • Classes are composed from structural and behavioral parts.
• Programming languages that include classes as a programming
construct offer support, for various class-related features, and the
syntax required to use these features varies greatly from one
programming language to another.
Objects and Classes
24. Design and implementation of a class?
• A class is a template that defines attributes and methods of a real-
word object.
Defining a Class:
• A class definition defines attributes and methods that are members
of the class. A Class definition using C++ is as follows:
Keyword class
Class name
Class body
Objects and Classes
25. What is meant by attribute of a class?
An attribute of a class is a variable called an instance variable.
Declaring an Instance Variable:
A declaration statement in Java or C++ consists of the following three
parts:
1) Data type.
2) Instance variable name.
3) Semicolon.
Objects and Classes
26. Data Type:
• A data type is a keyword that tells the computer the kind of data
you want to store in a memory location.
• The data type implies to the computer how much memory to
reserve and how to handle the data stored once it is stored at that
memory location.
• it is very important that you have a strong understanding of what a
data type is and how to specify a data type when declaring a
variable.
Data Types
29. Examples of data Types:
• You tell the computer to reserve space for an integer by using the
data type int. The computer already knows how much memory to
reserve to store an integer.
• The data type also tells the computer the kind of data that will be
stored at the memory location. This is important because
computers manipulate data of some data types differently than
data of other data types. This is similar to the warehouse manager
who treats a case of fuel oil differently than a case of baseballs.
Data Types
30. Instance variable name:
• The name of an instance variable is given by the programmer.
• It should represent the nature of the data stored at the memory
location. The variable name is used throughout the program to
refer to the contents of the corresponding memory location.
• For example, studentNumber is a perfect name for a variable used
to store a student number because the name tells you the nature
of the data associated with the variable.
• The variable name is used throughout the program to refer to the
contents of the corresponding memory location.
Data Types
33. Instance variable name:
• An instance variable is a type of class attribute (or class property,
field, or data member). The same differences between instance
and class members applies to methods (functions). Therefore, a
class may have both instance method and class method.
Data Types