SlideShare a Scribd company logo
1 of 58
Object Oriented Concepts
and
Class Modeling
Preeti Mishra
Course Instructor
Motivation
• You got a gun
• You were the proud owner of the nice gun!
• You used it:
• You claimed you know how to use a gun!
Object
• Any real world entity: chair, fan, student, cow
• Object has crisp boundaries
• You can physically or logically perceive an object
• Object has:
• State ( values of attributes)
• Behavior( method response)
• Identity( address+name)
Taking about the dog
Attributes(these will be common
to all dogs)
State( talking about dog obove)
Breed Labrador
Owner Mr. crazy
Batch_no 420_IM
Vaccinated No
Hobbies Music
badhabbits smoking
• Behavior:
• gets_vaccination
• Runs
• Listensongs….
• Identity:
• Batch_no ( it is unique for all dogs)
Task:
• Think of an object
• Give its state-
• Now deduce the attributes from this
state
• Talk of the identity
Abstraction
Object Oriented
Concepts:
What we learned
• People tend to see the same thing in
different manner
• Why So??
– Due to various perspectives, interests
• Technically we will refer this syndrome as
Abstraction
What is..
• An abstraction focuses on the outside view of an object and
separates an object’s behaviour from its implementation
• a simplified description, or specification, of a system that
emphasizes some of the system's details or properties while
suppressing others.
• A good abstraction is one that emphasizes details that are
significant to the reader or user and suppresses details that are,
at least for the moment, immaterial or diversionary“
• Nearly all programming languages designed since 1980
support data abstraction
Thus
• “An abstraction denotes the essential characteristics of an
object that distinguish it from all other kinds of objects and thus
provide crisply defined conceptual boundaries,
relative to the perspective of the viewer”
-Grady Booch
Realized in programming by..
• Abstract data types/ classes
• Abstract keyword
• Class…
Encapsulation
Need??
• Large programs have two special needs:
– Some means of organization, other than simply division into
subprograms
– Some means of partial compilation (compilation units that
are smaller than the whole program)
Hence encapsulation
• “Encapsulation is a mechanism used to hide the data, internal
structure, and implementation details of an object.
• All interaction with the object is through a public interface of
operations.”
• Abstraction and encapsulation are complementary concepts:
abstraction focuses upon the observable behaviour of an
object, whereas encapsulation focuses upon the
implementation that gives rise to this behaviour.
• For abstraction to work, implementations must be
encapsulated"
Defined as..
• “Encapsulation is the process of compartmentalizing
the elements of an abstraction that constitute its
structure and behaviour; encapsulation serves to
separate the contractual interface of an abstraction
and its implementation.”
– Grady Booch
Encapsulation is achieved through
• Encapsulation is most often achieved through information
hiding, which is the process of hiding all the secrets of an
object that do not contribute to its essential characteristics;
typically, the structure of an object is hidden, as well as the
,implementation of its methods.
In programming
• Encapsulation Abstraction= Class
• For eg: think of a person as student
• From this perspective think of his description/properties
• Now compartmentalize these properties into:
– attributes + behavior
– Make attributes as : member variables/ data members
– Make behavior: member functions/ methods
– Name the entity as some noun : Student (because its meaningful
according to the perspective)
And we have..
Class Student
{
int roll_no, marks;
String Name, branch, year;
int get_Attendence()
int check_percentage()
Modularity
Thus
• The act of partitioning a program into individual
components can reduce its complexity to some degree. .
• Although partitioning a program is helpful for this reason, a
more powerful justification for partitioning a program is that
it creates a number of well defined, documented
boundaries within the program.
Why Modularity??
• modularization consists of dividing a program into modules
which can be compiled separately, but which have
connections with other modules.
• The overall goal of the decomposition into modules is the
reduction of software cost by allowing modules to be
designed and revised independently. .
Defined as..
• Modularity is the property of a system that has been
decomposed into a set of cohesive and loosely coupled
modules
Heirarcy
What is the need
• A set of abstractions often forms a hierarchy, and by
identifying these hierarchies in our ,design, we greatly simplify
our understanding of the problem
Defined as..
• Hierarchy is a ranking
or ordering of
abstractions.
• Is-a relation
• Kind-of
Polymorphism
We learned
• Generally, the ability to appear in many forms.
• The same invocation can produce “many forms” of
results
• The same method name and signature can cause
different actions to occur,
– depending on the type of object on which the
method is invoked
• Promotes extensibility
• New objects types can respond to existing method
calls
• Polymorphism exists when the features of inheritance
and dynamic binding interact. It is
perhaps the most powerful feature of object-oriented
programming languages
Defined as..
• In object-oriented programming, polymorphism refers to
a programming language's ability to process objects
differently depending on their data type or class. More
specifically, it is the ability to redefine methods for
derived classes.
Object
•State
•Behavior/ operations
•Identity
•Roles-responsibility
•Life span
What is an Object?
• From the perspective of human
cognition, an object is any of the
following:
– A tangible and/or visible thing
– Something that may be
apprehended intellectually
– Something toward which thought
or action is directed
– something that exists in time and
space.
Defined as
• An object has state, behaviour, and identity; the structure and
behaviour of similar objects are defined in their common class;
the terms instance and object are interchangeable.
Object: State
Property
(attribute)
Current value(State)
Amount of money $45
No to slots 20
No of empty slots 5
No of filled slots 10
Price per slot …
State: defined as
• The state of an object encompasses all of the
(usually static) properties of the object plus the
current (usually dynamic) values of each of these
properties.
Behavior
• the behaviour of an object
represents its outwardly
visible and testable activity
• behaviour also notes that
the state of an object affects
its behaviour as well.
Behavior : defined as
• Behaviour is how an object acts and reacts, in terms
of its state changes and message passing.
• Thus:
– The state of an object represents the cumulative results of its
behaviour
Operations: means to show behaviour
(Operation/methods/memberfunctions)
• An operation denotes a service that a class offers to its clients.
• In practice, we have found that a client typically performs five kinds of
operations upon an object:
– Modifier :An operation that alters the state of an object
– Selector :An operation that accesses the state of an object, but does not alter the
state
– Iterator :An operation that permits all parts of an object to be accessed in some
well-defined order
– Constructor: An operation that creates an object and/or initializes its state
– Destructor An operation that frees the state of an object and/or destroys the
object itself
Task to do
• For a Stack data structure
identify :
• State: properties and
current values
• Behavior
• Operations of different
categories
Identity
Identity: defined as
• “Identity is that property of an object which
distinguishes it from all other objects "
Roles and Responsibilities
• all of the methods and free subprograms associated with a
particular object comprise its protocol.
Roles
• object's allowable behaviour, and so comprises the entire static and
dynamic view of the object.
• For most nontrivial abstractions, it is useful to divide this larger
protocol into logical groupings of behavior.
• These collections, which thus partition the behavior space
• of an object, denote the roles that an object can play.
• a role is a mask that an object wears , and so defines a contract
between an abstraction and its clients
Responsibility
• The responsibilities of an object to "include two key items:
– the knowledge an object maintains and
– the actions an object can perform.
• Responsibilities are meant to convey a sense of the purpose
of an object and its place in the system.
• The responsibilities of an object are all the services it
provides for all of the contracts it supports"
Object : Life Span
• Object Life Span :The lifetime of an object extends from the
time it is first created (and thus first consumes space) until that
space is reclaimed .
• To explicitly create an object, we must either declare it or
allocate it.
• Object destruction may vary …
• Persistent objects have slightly different semantics regarding
destruction

More Related Content

What's hot

10 architectural design (1)
10 architectural design (1)10 architectural design (1)
10 architectural design (1)
Ayesha Bhatti
 
Unit 3 3 architectural design
Unit 3 3 architectural designUnit 3 3 architectural design
Unit 3 3 architectural design
Hiren Selani
 
Design process and concepts
Design process and conceptsDesign process and concepts
Design process and concepts
Slideshare
 
Data and functional modeling
Data and functional modelingData and functional modeling
Data and functional modeling
Slideshare
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
Mahesh Bhalerao
 
4 agile modeldevelopement-danielleroux
4 agile modeldevelopement-danielleroux4 agile modeldevelopement-danielleroux
4 agile modeldevelopement-danielleroux
IBM
 
Modelling System Requirements: Events & Things
Modelling System Requirements: Events & ThingsModelling System Requirements: Events & Things
Modelling System Requirements: Events & Things
wmomoni
 
Function oriented design
Function oriented designFunction oriented design
Function oriented design
Vidhun T
 

What's hot (19)

10 architectural design (1)
10 architectural design (1)10 architectural design (1)
10 architectural design (1)
 
Unit 3 3 architectural design
Unit 3 3 architectural designUnit 3 3 architectural design
Unit 3 3 architectural design
 
Structural modeling and analysis
Structural modeling and analysisStructural modeling and analysis
Structural modeling and analysis
 
Object model
Object modelObject model
Object model
 
Design process and concepts
Design process and conceptsDesign process and concepts
Design process and concepts
 
Software Design Concepts
Software Design ConceptsSoftware Design Concepts
Software Design Concepts
 
Data and functional modeling
Data and functional modelingData and functional modeling
Data and functional modeling
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Design and Implementation in Software Engineering
Design and Implementation in Software EngineeringDesign and Implementation in Software Engineering
Design and Implementation in Software Engineering
 
Design concepts and design principles
Design concepts and design principlesDesign concepts and design principles
Design concepts and design principles
 
4 agile modeldevelopement-danielleroux
4 agile modeldevelopement-danielleroux4 agile modeldevelopement-danielleroux
4 agile modeldevelopement-danielleroux
 
Modelling System Requirements: Events & Things
Modelling System Requirements: Events & ThingsModelling System Requirements: Events & Things
Modelling System Requirements: Events & Things
 
Object oriented analysis and design unit- iv
Object oriented analysis and design unit- ivObject oriented analysis and design unit- iv
Object oriented analysis and design unit- iv
 
Function oriented design
Function oriented designFunction oriented design
Function oriented design
 
Software analysis and it's principles
Software analysis and it's principlesSoftware analysis and it's principles
Software analysis and it's principles
 
Analysis modeling
Analysis modelingAnalysis modeling
Analysis modeling
 
Lecture 14 requirements modeling - flow and behavior
Lecture 14   requirements modeling - flow and  behaviorLecture 14   requirements modeling - flow and  behavior
Lecture 14 requirements modeling - flow and behavior
 
4 sdlc
4 sdlc4 sdlc
4 sdlc
 
Functional modeling
Functional modelingFunctional modeling
Functional modeling
 

Viewers also liked (9)

C++0x
C++0xC++0x
C++0x
 
Object modeling
Object modelingObject modeling
Object modeling
 
Unit 8 software quality and matrices
Unit 8 software quality and matricesUnit 8 software quality and matrices
Unit 8 software quality and matrices
 
architectural design
 architectural design architectural design
architectural design
 
Unit 7 performing user interface design
Unit 7 performing user interface designUnit 7 performing user interface design
Unit 7 performing user interface design
 
Component level design
Component   level designComponent   level design
Component level design
 
software development, process model, requirement engineering, srs, structured...
software development, process model, requirement engineering, srs, structured...software development, process model, requirement engineering, srs, structured...
software development, process model, requirement engineering, srs, structured...
 
Project report On MSM (Mobile Shop Management)
Project report On MSM (Mobile Shop Management)Project report On MSM (Mobile Shop Management)
Project report On MSM (Mobile Shop Management)
 
Architecture design in software engineering
Architecture design in software engineeringArchitecture design in software engineering
Architecture design in software engineering
 

Similar to Oo concepts and class modeling

Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "
AchrafJbr
 
Object analysis and design
Object analysis and designObject analysis and design
Object analysis and design
Anand Grewal
 

Similar to Oo concepts and class modeling (20)

Introduction
IntroductionIntroduction
Introduction
 
Objects and Classes.pptx
Objects and Classes.pptxObjects and Classes.pptx
Objects and Classes.pptx
 
Objects and Classes.pptx
Objects and Classes.pptxObjects and Classes.pptx
Objects and Classes.pptx
 
Objects and Classes BRIEF.pptx
Objects and Classes BRIEF.pptxObjects and Classes BRIEF.pptx
Objects and Classes BRIEF.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Lukito Edi Nugroho - Object Orientation Concepts
Lukito Edi Nugroho - Object Orientation ConceptsLukito Edi Nugroho - Object Orientation Concepts
Lukito Edi Nugroho - Object Orientation Concepts
 
Ooad ch 1_2
Ooad ch 1_2Ooad ch 1_2
Ooad ch 1_2
 
07 intro2 oop
07 intro2 oop07 intro2 oop
07 intro2 oop
 
Design Pattern lecture 4
Design Pattern lecture 4Design Pattern lecture 4
Design Pattern lecture 4
 
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 Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "
 
Object analysis and design
Object analysis and designObject analysis and design
Object analysis and design
 
Ooad unit – 1 introduction
Ooad unit – 1 introductionOoad unit – 1 introduction
Ooad unit – 1 introduction
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptx
 
Ooad ch 2
Ooad ch 2Ooad ch 2
Ooad ch 2
 
Analysis
AnalysisAnalysis
Analysis
 
oomd-unit-i-cgpa.ppt
oomd-unit-i-cgpa.pptoomd-unit-i-cgpa.ppt
oomd-unit-i-cgpa.ppt
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptx
 
Introducción al Análisis y Diseño Orientado a Objetos
Introducción al Análisis y Diseño Orientado a ObjetosIntroducción al Análisis y Diseño Orientado a Objetos
Introducción al Análisis y Diseño Orientado a Objetos
 
Object model
Object modelObject model
Object model
 

More from Preeti Mishra

More from Preeti Mishra (18)

Effective Ways to Conduct Programming labs
Effective Ways to Conduct Programming labsEffective Ways to Conduct Programming labs
Effective Ways to Conduct Programming labs
 
Component diagram
Component diagramComponent diagram
Component diagram
 
Activity diag
Activity diagActivity diag
Activity diag
 
Object diagram
Object diagramObject diagram
Object diagram
 
Sequence diagrams
Sequence diagramsSequence diagrams
Sequence diagrams
 
State chart diagram
State chart diagramState chart diagram
State chart diagram
 
Use case Diagram
Use case DiagramUse case Diagram
Use case Diagram
 
testing strategies and tactics
 testing strategies and tactics testing strategies and tactics
testing strategies and tactics
 
requirements analysis and design
requirements analysis and designrequirements analysis and design
requirements analysis and design
 
Design process interaction design basics
Design process interaction design basicsDesign process interaction design basics
Design process interaction design basics
 
Design process design rules
Design process  design rulesDesign process  design rules
Design process design rules
 
Foundations understanding users and interactions
Foundations  understanding users and interactionsFoundations  understanding users and interactions
Foundations understanding users and interactions
 
IntrIntroduction
IntrIntroductionIntrIntroduction
IntrIntroduction
 
Software testing part
Software testing partSoftware testing part
Software testing part
 
eUnit 2 software process model
eUnit 2  software process modeleUnit 2  software process model
eUnit 2 software process model
 
Unit 1 importance ofsoftengg_b.tech iii year
Unit 1  importance ofsoftengg_b.tech iii yearUnit 1  importance ofsoftengg_b.tech iii year
Unit 1 importance ofsoftengg_b.tech iii year
 
Unit 1 introduction tosoftengg_mba tech ii year
Unit 1  introduction tosoftengg_mba tech ii yearUnit 1  introduction tosoftengg_mba tech ii year
Unit 1 introduction tosoftengg_mba tech ii year
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 

Recently uploaded

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 

Recently uploaded (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 

Oo concepts and class modeling

  • 1. Object Oriented Concepts and Class Modeling Preeti Mishra Course Instructor
  • 2. Motivation • You got a gun • You were the proud owner of the nice gun! • You used it: • You claimed you know how to use a gun!
  • 3. Object • Any real world entity: chair, fan, student, cow • Object has crisp boundaries • You can physically or logically perceive an object • Object has: • State ( values of attributes) • Behavior( method response) • Identity( address+name)
  • 4.
  • 5. Taking about the dog Attributes(these will be common to all dogs) State( talking about dog obove) Breed Labrador Owner Mr. crazy Batch_no 420_IM Vaccinated No Hobbies Music badhabbits smoking
  • 6. • Behavior: • gets_vaccination • Runs • Listensongs…. • Identity: • Batch_no ( it is unique for all dogs)
  • 7. Task: • Think of an object • Give its state- • Now deduce the attributes from this state • Talk of the identity
  • 9.
  • 10. What we learned • People tend to see the same thing in different manner • Why So?? – Due to various perspectives, interests • Technically we will refer this syndrome as Abstraction
  • 11. What is.. • An abstraction focuses on the outside view of an object and separates an object’s behaviour from its implementation • a simplified description, or specification, of a system that emphasizes some of the system's details or properties while suppressing others. • A good abstraction is one that emphasizes details that are significant to the reader or user and suppresses details that are, at least for the moment, immaterial or diversionary“ • Nearly all programming languages designed since 1980 support data abstraction
  • 12.
  • 13.
  • 14. Thus • “An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of objects and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer” -Grady Booch
  • 15. Realized in programming by.. • Abstract data types/ classes • Abstract keyword • Class…
  • 17. Need?? • Large programs have two special needs: – Some means of organization, other than simply division into subprograms – Some means of partial compilation (compilation units that are smaller than the whole program)
  • 18.
  • 19. Hence encapsulation • “Encapsulation is a mechanism used to hide the data, internal structure, and implementation details of an object. • All interaction with the object is through a public interface of operations.” • Abstraction and encapsulation are complementary concepts: abstraction focuses upon the observable behaviour of an object, whereas encapsulation focuses upon the implementation that gives rise to this behaviour. • For abstraction to work, implementations must be encapsulated"
  • 20. Defined as.. • “Encapsulation is the process of compartmentalizing the elements of an abstraction that constitute its structure and behaviour; encapsulation serves to separate the contractual interface of an abstraction and its implementation.” – Grady Booch
  • 21. Encapsulation is achieved through • Encapsulation is most often achieved through information hiding, which is the process of hiding all the secrets of an object that do not contribute to its essential characteristics; typically, the structure of an object is hidden, as well as the ,implementation of its methods.
  • 22. In programming • Encapsulation Abstraction= Class • For eg: think of a person as student • From this perspective think of his description/properties • Now compartmentalize these properties into: – attributes + behavior – Make attributes as : member variables/ data members – Make behavior: member functions/ methods – Name the entity as some noun : Student (because its meaningful according to the perspective)
  • 23. And we have.. Class Student { int roll_no, marks; String Name, branch, year; int get_Attendence() int check_percentage()
  • 25.
  • 26.
  • 27.
  • 28. Thus • The act of partitioning a program into individual components can reduce its complexity to some degree. . • Although partitioning a program is helpful for this reason, a more powerful justification for partitioning a program is that it creates a number of well defined, documented boundaries within the program.
  • 29. Why Modularity?? • modularization consists of dividing a program into modules which can be compiled separately, but which have connections with other modules. • The overall goal of the decomposition into modules is the reduction of software cost by allowing modules to be designed and revised independently. .
  • 30. Defined as.. • Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules
  • 32.
  • 33.
  • 34. What is the need • A set of abstractions often forms a hierarchy, and by identifying these hierarchies in our ,design, we greatly simplify our understanding of the problem
  • 35. Defined as.. • Hierarchy is a ranking or ordering of abstractions.
  • 38.
  • 39.
  • 40. We learned • Generally, the ability to appear in many forms. • The same invocation can produce “many forms” of results • The same method name and signature can cause different actions to occur, – depending on the type of object on which the method is invoked • Promotes extensibility • New objects types can respond to existing method calls
  • 41.
  • 42. • Polymorphism exists when the features of inheritance and dynamic binding interact. It is perhaps the most powerful feature of object-oriented programming languages
  • 43. Defined as.. • In object-oriented programming, polymorphism refers to a programming language's ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes.
  • 45. What is an Object? • From the perspective of human cognition, an object is any of the following: – A tangible and/or visible thing – Something that may be apprehended intellectually – Something toward which thought or action is directed – something that exists in time and space.
  • 46. Defined as • An object has state, behaviour, and identity; the structure and behaviour of similar objects are defined in their common class; the terms instance and object are interchangeable.
  • 47. Object: State Property (attribute) Current value(State) Amount of money $45 No to slots 20 No of empty slots 5 No of filled slots 10 Price per slot …
  • 48. State: defined as • The state of an object encompasses all of the (usually static) properties of the object plus the current (usually dynamic) values of each of these properties.
  • 49. Behavior • the behaviour of an object represents its outwardly visible and testable activity • behaviour also notes that the state of an object affects its behaviour as well.
  • 50. Behavior : defined as • Behaviour is how an object acts and reacts, in terms of its state changes and message passing. • Thus: – The state of an object represents the cumulative results of its behaviour
  • 51. Operations: means to show behaviour (Operation/methods/memberfunctions) • An operation denotes a service that a class offers to its clients. • In practice, we have found that a client typically performs five kinds of operations upon an object: – Modifier :An operation that alters the state of an object – Selector :An operation that accesses the state of an object, but does not alter the state – Iterator :An operation that permits all parts of an object to be accessed in some well-defined order – Constructor: An operation that creates an object and/or initializes its state – Destructor An operation that frees the state of an object and/or destroys the object itself
  • 52. Task to do • For a Stack data structure identify : • State: properties and current values • Behavior • Operations of different categories
  • 54. Identity: defined as • “Identity is that property of an object which distinguishes it from all other objects "
  • 55. Roles and Responsibilities • all of the methods and free subprograms associated with a particular object comprise its protocol.
  • 56. Roles • object's allowable behaviour, and so comprises the entire static and dynamic view of the object. • For most nontrivial abstractions, it is useful to divide this larger protocol into logical groupings of behavior. • These collections, which thus partition the behavior space • of an object, denote the roles that an object can play. • a role is a mask that an object wears , and so defines a contract between an abstraction and its clients
  • 57. Responsibility • The responsibilities of an object to "include two key items: – the knowledge an object maintains and – the actions an object can perform. • Responsibilities are meant to convey a sense of the purpose of an object and its place in the system. • The responsibilities of an object are all the services it provides for all of the contracts it supports"
  • 58. Object : Life Span • Object Life Span :The lifetime of an object extends from the time it is first created (and thus first consumes space) until that space is reclaimed . • To explicitly create an object, we must either declare it or allocate it. • Object destruction may vary … • Persistent objects have slightly different semantics regarding destruction