SlideShare a Scribd company logo
1 of 33
Download to read offline
Object Oriented
Programming
Lecture (1)
Dr. Abdelrahman Mohamed
El-Akhdar
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
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
 A Look at How We See the World.
 Objects.
 Abstract Objects and Instances.
 Classes and structures.
 Objects and classes.
 Methods.
Lecture Outlines
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
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.
 A Look at How We See the World.
 Objects.
 Abstract Objects and Instances.
 Classes and structures.
 Objects and classes.
 Methods.
Lecture Outlines
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.
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
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
 A Look at How We See the World.
 Objects.
 Abstract Objects and Instances.
 Classes and structures.
 Objects and classes.
 Methods.
Lecture Outlines
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
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
 A Look at How We See the World.
 Objects.
 Abstract Objects and Instances.
 Classes and structures.
 Objects and classes.
 Methods.
Lecture Outlines
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.
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
 A Look at How We See the World.
 Objects.
 Abstract Objects and Instances.
 Classes and structures.
 Objects and classes.
 Methods.
Lecture Outlines
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
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
• 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
Example of a class
Objects and Classes
Another example of a class
Objects and Classes
A class definition in C++ code
Objects and Classes
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
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
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
Data Type in C++:
Data Types
Data Type in Java:
Data Types
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
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
Instance variable name:
Data Types
Thank you
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

More Related Content

Similar to OOP Lecture (1) Object and Class Concepts

It 405 materi 3 objek dan kelas
It 405 materi 3   objek dan kelasIt 405 materi 3   objek dan kelas
It 405 materi 3 objek dan kelasAyi Purbasari
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisLuis Goldster
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisYoung Alista
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisHoang Nguyen
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisFraboni Ec
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisTony Nguyen
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisJames Wong
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisHarry Potter
 
Concept of Object-Oriented in C++
Concept of Object-Oriented in C++Concept of Object-Oriented in C++
Concept of Object-Oriented in C++Abdullah Jan
 
Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Ganapathi M
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane1
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptRushikeshChikane2
 
introduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptintroduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptrekhasai2468
 
Handout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and DesignHandout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and DesignSAFAD ISMAIL
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented DesignAravinth NSP
 

Similar to OOP Lecture (1) Object and Class Concepts (20)

It 405 materi 3 objek dan kelas
It 405 materi 3   objek dan kelasIt 405 materi 3   objek dan kelas
It 405 materi 3 objek dan kelas
 
Ooad unit – 1 introduction
Ooad unit – 1 introductionOoad unit – 1 introduction
Ooad unit – 1 introduction
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Concept of Object-Oriented in C++
Concept of Object-Oriented in C++Concept of Object-Oriented in C++
Concept of Object-Oriented in C++
 
[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects
 
Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0
 
Ooad ch 1_2
Ooad ch 1_2Ooad ch 1_2
Ooad ch 1_2
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.pptChapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
 
introduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.pptintroduction-to-dbms-unit-1.ppt
introduction-to-dbms-unit-1.ppt
 
Handout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and DesignHandout on Object orienetd Analysis and Design
Handout on Object orienetd Analysis and Design
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 
Object Oriented Design
Object Oriented DesignObject Oriented Design
Object Oriented Design
 

Recently uploaded

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

OOP Lecture (1) Object and Class Concepts

  • 1. Object Oriented Programming Lecture (1) Dr. Abdelrahman Mohamed El-Akhdar
  • 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
  • 21. Example of a class Objects and Classes
  • 22. Another example of a class Objects and Classes
  • 23. A class definition in C++ code 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
  • 27. Data Type in C++: Data Types
  • 28. Data Type in Java: 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