0% found this document useful (0 votes)
35 views23 pages

Slide 4

This document discusses object-oriented programming principles including inheritance, object models, and different programming paradigms. It covers key characteristics of inheritance like generalization and specialization. It also addresses handling issues that can arise with multiple inheritance like name clashes. The document defines objects and describes their properties like state, behavior, and identity. It explains the relationship between classes and objects and different types of class interfaces. Finally, it discusses the popularity of various object-oriented languages and programming paradigms like procedural, functional, object-oriented, and logic programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views23 pages

Slide 4

This document discusses object-oriented programming principles including inheritance, object models, and different programming paradigms. It covers key characteristics of inheritance like generalization and specialization. It also addresses handling issues that can arise with multiple inheritance like name clashes. The document defines objects and describes their properties like state, behavior, and identity. It explains the relationship between classes and objects and different types of class interfaces. Finally, it discusses the popularity of various object-oriented languages and programming paradigms like procedural, functional, object-oriented, and logic programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Object Oriented Programming

aft
(CS F213)
Object Oriented Principles,
Elements and Object Model - 2
Aritra Mukherjee
Dept of CSIS, BITS Pilani, Hyderabad Campus

Dr
More on Inheritance
The properties of inheritance
Handling multiple inheritance

Object Model
More on it
Objects- what’s the big deal?!
class - a Class apart!

Object Oriented Paradigm


Different Languages

CS F213 a.mukherjee 2
More on Inheritance

Inheritance is one of the most important paradigms of OOP as it brings the


hiearchical structure in logic, that mimics most of the complicated real world
scenarios.
Characteristics of Inheritance:
▶ Inheritance is the most important“is a” hierarchy
▶ Thus we have single inheritance and multiple inheritance
▶ Inheritance thus implies generalization and specialization hierarchy
▶ A subclass specializes the more general structure or behavior of the superclass
▶ If A is not kind of B, then A should not inherit B

CS F213 a.mukherjee 3
Types of Inheritance

CS F213 a.mukherjee 4
Characteristics of Inheritance:

▶ As we evolve our inheritance hierarchy the structure and behavior that are
common to different classes will tend to common superclasses
▶ Superclass represents generalized abstractions
▶ Subclasses represent specialization of superclasses
▶ Multiple Inheritance is conceptually straightforward, but induces some practical
complexities for programming languages

Perils of multiple inheritance


We have to resolve:
1. name clashes
2. repeated inheritance

CS F213 a.mukherjee 5
Handling multiple inheritance

Name clash
1. C++ resolves the name clash by attaching the classname qualifier called “virtual”
2. python uses C3 liearization to handle this problem

Repeated inheritance
1. This occurs when two or more peer superclasses share a common superclass
2. In such situation, the inheritance lattice will be a diamond, and so the question
arises, does the leaf class have one copy or multiple copies of the structure of the
shared superclass
3. Most of the cases, multiple inheritance is misused. Hence it is prohibited by some
languages

CS F213 a.mukherjee 6
Object Model

▶ Object model does not abandon the sound principles of


process-oriented model
▶ Rather it introduces several novel elements that build
upon these earlier models
▶ The use of Object model helps us to construct well-
structured complex systems

CS F213 a.mukherjee 7
Benifits of Object Model

▶ Object model helps us to exploit the expressive power of object


based languages
▶ Reuse of code and Design both, leading to frameworks and
engines
▶ Systems are more resilient to change
▶ Develop more complex systems with confidence and correctness
▶ Humans find the idea of object orientation quite natural

CS F213 a.mukherjee 8
Objects

▶ The ability to recognize the physical objects is a skill humans possesses


▶ We understand that an object is a tangible entity that exhibits some well-defined
behavior

An object can be any of the following:


1. A tangible and/or visible thing
2. Something towards which our thought or action is directed
3. Something that may be understood intellectually

CS F213 a.mukherjee 9
Objects

▶ Real-world objects are not the only kind of objects that are of
interest to us in Software development
▶ Other important kinds of objects are inventions of the design
process whose collaboration with other such objects to provide
some high-level behavior or functionality
▶ An object represents an individual, identifiable item, unit, or
entity either in the real world or abstract, with a well-defined
role in the problem domain
▶ Speed, color, temp etc. can not become objects. These are
actually properties of other objects
CS F213 a.mukherjee 10
Properties of Object

An object has state, behavior, and identity

▶ The structure and behavior of similar objects


are defined in their common class
▶ The terms instance and object are
interchangeable

CS F213 a.mukherjee 11
State and Identity

State of an object
▶ The state of an object encompasses all the properties (usually static) of an object
plus the current (usually dynamic) values of each of these properties
▶ All properties have values- simple or another object

Examples
Identity
▶ Identity is that property of an object which distinguishes it from all other objects
▶ It can be a programmer imposed key or simply the reference to the object

CS F213 a.mukherjee 12
Behaviour

Behaviour
▶ Objects don’t stay in isolation
▶ They keep interacting with each other
▶ They act upon others and similarly are acted upon by other objects
▶ Behavior is how an object acts and reacts, in terms of its state changes
and message passing
▶ We use the terms operation and message interchangeably

CS F213 a.mukherjee 13
Class

▶ A class represents a set of objects that share a common


structure and a common behavior
▶ A single object is an instance of a class
▶ An individual object is a concrete entity that performs some role
in the overall system
▶ The class captures the structure and behavior common to all
related objects

CS F213 a.mukherjee 14
Class

▶ The interface of a class provides its outside view and therefore


helps in hiding the structure and secrets of behavior
▶ By contrast the implementation of a class is its inside view,
which encompasses the secrets of its behavior
▶ Types of interfaces:
1. Public
2. Private
3. Protected

CS F213 a.mukherjee 15
Relationship among classes

CS F213 a.mukherjee 16
Different OO Languages

The most commonly used object oriented languages are C++, Java and Python
Other languages
▶ pure object oriented languages (everything is an object): Ruby, Scala, Smalltalk,
Eiffel, Emerald, JADE, Self, Raku.
▶ mainly OO with partial procedural elements: Java, Python, C++, C#, Delphi or
Object Pascal, VB dot NET.
▶ mainly procedural with partial OO characteristics: PHP, Perl, Visual Basic
(derived from BASIC), MATLAB, COBOL 2002, Fortran 2003, ABAP, Ada 95,
Pascal.

CS F213 a.mukherjee 17
Popularity of languages

CS F213 a.mukherjee 18
Popularity of languages

CS F213 a.mukherjee 19
Programming paradigms

CS F213 a.mukherjee 20
Programming paradigms
▶ Procedural Programming Languages The Procedural Programming Languages
paradigm, derived from structured programming, specifies a series of
well-structured procedures and steps to compose a program.
BASIC, C, Java, PASCAL, and FORTRAN
▶ Functional Programming Languages A functional programming language is a
declarative programming paradigm where programs are constructed by applying
and composing functions. The language emphasizes expressions and declarations
primarily
Haskell, SML, Scala, F#, ML, and Scheme
▶ Object-oriented programming Language Object-oriented programming
Languages are based on “objects” i.e. units that contain data in the form of fields
and code in the form of procedures. OOP offers many features like abstraction,
encapsulation, polymorphism, inheritance, and classes
Java, C++, C#, Python, Javascript, ...
CS F213 a.mukherjee 21
Programming paradigms

▶ Scripting Programming Languages All scripting languages are programming


languages that do not require a compilation step. Rather, they are interpreted
(there is no compile stage). The instructions are written for a run time
environment.
Javascript, PHP, and PERL for server side scripting; Javascript, AJAX, Jquery;
Shell for client side scripting, PERL, Python for system administration; and Ruby
for web development.
▶ Logic Programming The programming paradigm is largely based on formal logic.
The language does not tell the machine how to do something but employs
restrictions on what it must consider doing.
PROLOG, LISP, ASAP(Answer Set programming), and Datalog are well known
logic programming languages, with the rules written in the form of classes.

CS F213 a.mukherjee 22
Discussion Time!

CS F213 a.mukherjee 23

You might also like