Lecture 1
Lecture 1
This subject aims to focuses on Advanced concept of C++ and advanced data structure to
1.
students. It focuses on advanced level analysis of algorithm and computational mathematics.
3
Object Oriented Design
4
Motive
To explain how a software design maybe represented as a set of
interacting objects that manage their own state and operations.
5
What is class?
We can define a class by following ways:
An abstract data type.
or
A template data.
or
Collections of rules
or
Collection of different data types and certain functions which acts on
that data.
6
Example of class?
Name: Human
_____________________
Data types: height, length
weight etc.
_____________________
Functions:
walk(),speak(),movehand(),
smell() etc..
7
What is Object?
We can define a Object by following ways:
*Every object have its own memory area known as context area of an
object.
“Creation of Object means providing the memory to the member of
classes”
8
• Class text
•{
• Int I ,j ,k;
• Meth()
•{ I,j,k
• //FUNCTIONALITY Meth()
•}
•}
• Text ob;
• Text *ob=new Text() Context area of an Object
9
Example of Object?
Peter
10
Characteristics of OOD
Objects are abstractions of real-world or system entities and
manage themselves.
Objects are independent and encapsulate state and
representation information.
System functionality is expressed in terms of object services
Shared data areas are eliminated
Objects may be distributed
Objects communicate by message passing
Objects may execute sequentially or in parallel
11
Object Oriented Paradigm
Following are the paradigm of OOPs:
• Encapsulation
• Inheritance
• Polymorphism
12
Encapsulation
“Wrapping up data and function into a single unit is termed as
Encapsulation”.
We achieve data hiding fundamental form encapsulation (various
access modifiers).
E.g. Class.
class: login
______________________________
Variables:User name ,password
(private accessibility)
______________________________
Function:login(username,password)
13
Inheritance
“To achieve the properties (except private) form parent class (super
class ) to child class (sub class) is known as inheritance”.
“By inheritance a class, one is creating the same nomenclature of child
class as of its parent class ”.
Five types of inheritance are possible:
Single inheritance
Multilevel Inheritance
Multiple Inheritance
Hybrid Inheritance
Hierarchical Inheritance
14
[1]
15
Polymorphism
“One thing can be represented in many form is known polymorphism” .
We have two types of polymorphism:
“Super class reference variable can refer to the object of its subclass”
16
Class Abc Class test extends Abc
{ {
Void Abc() Void Abc()
{ {
fun1 fun2
} }
Main() }
{
ob.Abc()
}
}
17
Abstraction
“Hiding the complexity and showing essential feature”.
“A generic concept not limited to OOPs”.
E.g. Mobile phone. How my phone works internally
but I know how to make calls.
18
Implementation of OOD (Real Scenario)
Let's have an example of cell phone. Cell phone is treated as an object,
was invented for calling and messaging. But now numerous features are
adding day by day and still in progress. In figure each type of mobile
have its own features along with basic functionality.
Mobile
19
Implementation of OOD (Real Scenario)
Contd… class: Mobile
______________________________
Class : Properties:
A plan which describes the objects. No_Sim_slots
IEMIcode
Processor
Object:
______________________________
Mobile ob1=new Mobile(); Methods:
Mobile ob2=new Mobile(); Dial
Each object can behave different Connect_wifi
ConnectBluetooth
as per their characteristics. SendMessage
Recievemessage
20
Implementation of OOD (Real Scenario)
Contd…
A principle known as SOLID needs to be satisfied while creating a class:
1. SRP( The Single Responsibility Principle):A class should have one, and
only one responsibility.
2.OCP (The Open Closed Principle) - You should be able to extend a
classes behavior, without modifying it. (Inheritance)
3.LSP (The Liskov Substitution Principle) - Derived classes must be
substitutable for their base classes. (Polymorphism)
4.ISP (The Interface Segregation Principle) -Make fine chopped
interface instead of huge interface as client cannot be forced to
implement an interface which they don't use.
5.DIP (The Dependency Inversion Principle) - Depend on abstractions, 21
Implementation of OOD (Real Scenario)
Contd…
Abstraction:
To call anybody we just dial a number showed on screen but how we
don’t bother to know.
Press green icon to connect but we are unaware how it is doing.
Ex. Public void dial() /* Called by user without knowing the internal working*/
{
//certain logic to display the number
println(“Dial a number”);
}
22
Implementation of OOD (Real Scenario)
Contd…
Encapsulation:
Class :
Private IMEI mobile
code Instance
Public :
variable
Instance
Variable
Private methods
23
Implementation of OOD (Real Scenario)
Contd… Class Samsung: Mobile
{
Polymorphism: Public void dial()
Ex. {
println(“Dial a number”);
}
Public void dial( String mode)
{
println(“Dial a number with video”);
}
/*method overloading*/
}
24
Implementation of OOD (Real Scenario)
Contd…
Inheritance: Achieve reusability
Single Hierarchal
Samsung A9
25
Multilevel
Conclusion
By above example we can conclude by using four pillars of OOPs we can
develop a good program and connecting it with real world.
26
References
Images link-
[1] https://simplesnippets.tech/inheritance-in-java-types-of-inheritance/
Online Video Link-
• https://nptel.ac.in/courses/106/105/106105151/
Research Paper:
• http://onlinepubs.trb.org/Onlinepubs/trr/1993/1408/1408-012.pdf
• https://www.researchgate.net/publication/327633163_ADVANCE-RABIN_KARP_ALGORITHM_FOR_STRING_MATCHING
• https://glossary.informs.org/notes/spanningtree.pdf
For queries
Email: [email protected]
28