SlideShare a Scribd company logo
Workshop on
Object-oriented programming
FAHAD HUSSAIN
MCS, MSCS, DAE(CIT)
Computer Science Instructor of well known international Center
Also, Machine Learning and Deep learning Practitioner
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Object-oriented programming
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Object-oriented programming (OOP) is a programming paradigm based on the
concept of "objects", which can contain data, in the form of fields (often known
as attributes or properties), and code, in the form of procedures (often known as
methods). It is the programming concept based on bottom-up approach!
The main aim of OOP is to bind together the data and the functions that operate
on them so that no other part of the code can access this data except that
function.
Object-oriented programming
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Pillars of object-oriented programming
1)Encapsulation:
2)Inheritance:
3)Polymorphism:
4)Abstraction:
5)*Exception Handling
Class ,Object and Function/Method
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Before going into depth in OOP, let’s understand the 6 basic things!
1. What is class
2. What is object
3. What is namespaces
4. What is function/Method
5. What is Constructor and its types
6. What is Destructors
Class ,Object and Function/Method
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Class:
It is a user-defined data type, which holds its own data members and member functions, which can be
accessed and used by creating an instance of that class. A class is like a blueprint for an object.
In simple words, it is a prototype or building block structure for starting work in the OOP
approach!
Object:
An Object is an identifiable entity with some characteristics and behavior. An Object is an
instance of a Class. When a class is defined, no memory is allocated but when it is
instantiated (i.e. an object is created) memory is allocated.
Class ,Object and Function/Method
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Function VS Method:
A method is a code block that contains a series of statements according to the requirement
of the program! In OOP = Method and in procedure = Function
Namespaces
Namespaces in C# are used to organize too many classes so that it can be easy to handle the
application. We use System.Console where System is the namespace and Console is the
class. To access the class of a namespace, we need to use namespacename.classname. We
can use using keyword so that we don't have to use complete name all the time.
Constructor and its types
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
A constructor is a special method of the class which gets automatically invoked whenever an instance of
the class is created. Like methods, a constructor also contains the collection of instructions that are
executed at the time of Object creation. It is used to assign initial values to the data members of the
same class.
Types of Constructor
• Default Constructor
• Parametrized Constructor (with overload concept)
• Copy Constructor
• Private Constructor
• Static Constructor
Constructor and its types
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Default Constructor
A constructor with no parameters is called a default
constructor. A default constructor has every instance of
the class to be initialized to the same values. The
default constructor initializes all numeric fields to zero
and all string and object fields to null inside a class.
Constructor and its types
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Parameterized Constructor with overload
A constructor have at least one parameter is called
a parametrized constructor. It can initialize each
instance of the class to different values.
Constructor and its types
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Copy Constructor
This constructor will creates an object by copying
variables from another object. Its main use is to
initialize a new instance to the values of an existing
instance.
Constructor and its types
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Private Constructor
If a constructor is created with private specifier is known as Private
Constructor. It is not possible for other classes to derive from this
class and also it’s not possible to create an instance of this class.
Points To Remember :
use private constructor when we have only static members.
Using private constructor, prevents the creation of the instances of
that class.
Constructor and its types
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Static Constructor (no access modifier, no parameters)
Static Constructor has to be invoked only once in the class and it has been
invoked during the creation of the first reference to a static member in the class.
A static constructor is initialized static fields or data of the class and to be
executed only once.
Points To Remember :
It can’t be called directly.
When it is executing then the user has no control.
It does not take access modifiers or any parameters.
It is called automatically to initialize the class before the first instance created.
Constructor
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Important points to Remember About Constructors
• Constructor of a class must have the same name as the class name in
which it resides.
• A constructor can not be abstract, final, and Synchronized.
• Within a class, you can create only one static constructor.
• A constructor doesn’t have any return type, not even void.
• A static constructor cannot be a parameterized constructor.
• A class can have any number of constructors.
• Access modifiers can be used in constructor declaration to control its
access i.e. which other class can call the constructor.
Destructors
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Destructors in C# are methods inside the class used to destroy instances of that
class when they are no longer needed. The Destructor is called implicitly by the
.NET Framework's Garbage collector and therefore programmer has no control as
when to invoke the destructor
• In c#, destructors can be used only in classes and a class can contain only one destructor.
• The destructor in class can be represented by using tilde (~) operator
• The destructor in c# won’t accept any parameters and access modifiers.
• The destructor will invoke automatically, whenever an instance of class is no longer needed.
• The destructor automatically invoked by garbage collector whenever the class objects that
are no longer needed in application.
Till Now, We have Learn!
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
What is class
What is object
What is namespaces
What is function/Method
What is Constructor and its types
What is Destructor
Theory + Practical in C#,
Thank you Very Much, end of Workshop Part 1
Now, next we will discuss about the pillars from scratch!
Workshop on
Object-oriented programming
FAHAD HUSSAIN
MCS, MSCS, DAE(CIT)
Computer Science Instructor of well known international Center
Also, Machine Learning and Deep learning Practitioner
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Workshop Part 2
Till Now, We have Learn!
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
What is class
What is object
What is namespaces
What is function/Method
What is Constructor and its types
What is Destructor
Workshop Part 1
Object-oriented programming
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Pillars of object-oriented programming
1)Encapsulation:
2)Inheritance:
3)Polymorphism:
4)Abstraction:
5)*Exception Handling
Encapsulation
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
In object-oriented programming, encapsulation refers to the
bundling of data with the methods that operate on that data,
or the restricting of direct access to some of an object's
components.
Encapsulation, its can be accessed/done by Access Modifier /
Access Specifier
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Access modifiers (or access specifiers) are keywords in object-oriented
languages that set the accessibility of classes, methods, and other members. Access
modifiers are a specific part of programming language syntax used to facilitate the
encapsulation of components.
In the C#, there are Six access Modifier whereas just for information 4 in Java!
1. Public: The type or member can be accessed by any other code in the same assembly or another assembly that
references it.
2. Private: The type or member can be accessed only by code in the same class or struct.
3. Protected: The type or member can be accessed only by code in the same class, or in a class that is derived from
that class.
4. Internal : The type or member can be accessed by any code in the same assembly, but not from another assembly.
5. Protected Internal : The type or member can be accessed by any code in the assembly in which it is declared, or
from within a derived class in another assembly.
6. Private Protected: It access modifier is a combination of the private and protected keywords. We can access
members inside the containing class or in a class that derives from a containing class, but only in the same
assembly(project). Therefore, if we try to access it from another assembly, we will get an error. (C# 7.0)
In Java
Public Private Protected Default
Inheritance
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Object-Oriented programming language is code reuse. This reusability is possible due to the
relationship b/w the classes. Object oriented programming generally support 4 types of
relationships that are: inheritance , association, composition and aggregation. All these
relationship is based on "is a" relationship, "has-a" relationship and "part-of" relationship.
Inheritance
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Also, multiple and hybrid level, (preform by interface)
because in C#, and Java these are not allowed using
inheritance!
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Has a relationship:
Association is relation between two separate classes which establishes through
their Objects. Association can be one-to-one, one-to-many, many-to-one, many-to-
many.
In Object-Oriented programming, an Object communicates to other Object to use
functionality and services provided by that object. Composition and Aggregation are
the two forms of association.
Student has a ID, name etc…
also with new keyword!
Polymorphism
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
The word polymorphism means having many forms. In
object-oriented programming paradigm, polymorphism is
often expressed as 'one interface, multiple functions’.
Polymorphism
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Function Overloading
You can have multiple definitions for the same function name in the
same scope. The definition of the function must differ from each
other by the types and/or the number of arguments in the argument
list. You cannot overload function declarations that differ only by
return type.
Polymorphism
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Operator overloading:
The concept of overloading a function can also be applied
to operators. Operator overloading gives the ability to use
the same operator to do various operations.
Let’s understand the concept of + in the code…
Till Now, We have Learn!
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
1)What is Encapsulation:
2)Inheritance:
3)Polymorphism (only static or compile time)
Theory + Practical in C#,
Thank you Very Much, end of Workshop Part 2
Now, next we will discuss about the pillars (rest of the) from
scratch in the Last Session (Part 3)!
Workshop on
Object-oriented programming
FAHAD HUSSAIN
MCS, MSCS, DAE(CIT)
Computer Science Instructor of well known international Center
Also, Machine Learning and Deep learning Practitioner
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Workshop Part 3
Till Now, We have Learn!
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
What is class
What is object
What is namespaces
What is
function/Method
What is Constructor
and its types
What is Destructor
Workshop Part 1
1)What is Encapsulation:
2)Inheritance:
3)Polymorphism (only static
or compile time)
Workshop Part 2
Polymorphism
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
The word polymorphism means having many forms. In
object-oriented programming paradigm, polymorphism is
often expressed as 'one interface, multiple functions’.
Method Override … Method Hiding
Polymorphism
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Method Hiding:
For hiding the base class method from derived class
simply declare the derived class method with the new
keyword.
Method Overriding
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Run Time Polymorphism means overriding a base class method in
derived class by creating a similar function and this can be achieved
by using override & virtual keywords along
with inheritance principle.
By using run time polymorphism, we can override a base
class method in derived class by creating a method with same name
and parameters to perform a different task.
In c#, the run time polymorphism can be achieved by using method
overriding and it is also called as late binding or dynamic binding.
Abstraction
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Abstraction is the detail hiding of (implementation hiding).
Abstraction will be done by: Abstract class
• By using Abstraction you can used abstraction 0
to 100%!!!
Abstraction
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
Interface (It is special type of class but not exactly
class, containing the abstract method only) also used
for multiple inheritance in C#.
• By using Interface you can used abstraction
100%!!!
• Also, Interface used for multiple level
inheritance in C#, Java!
Exception Handling
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
 try – A try block is used to encapsulate a region of code. If any code throws an exception within that try
block, the exception will be handled by the corresponding catch.
 catch – When an exception occurs, the Catch block of code is executed. This is where you are able to
handle the exception, log it, or ignore it.
 finally – The finally block allows you to execute certain code if an exception is thrown or not. For
example, disposing of an object that must be disposed of.
 throw – The throw keyword is used to actually create a new exception that is the bubbled up to a try
catch finally block.
The try catch and finally block is a mechanism to detect and handle run-time errors in code.
It is provided by one of the built-in classes for common exceptions. The exceptions are anomalies that
occur during the execution of a program. They can be because of user, logic or system errors. If a user
(programmer) does not provide a mechanism to handle these anomalies, the compiler provide a default
mechanism, which terminates the program execution.
Finally
For further assistance, code and slide https://fahadhussaincs.blogspot.com/
What is class
What is object
What is namespaces
What is function/Method
What is Constructor and
its types
What is Destructor
Workshop Day 1, Part 1
1)What is Encapsulation:
2)Inheritance:
3)Polymorphism
(only static or compile time)
Workshop Day 2, Part 2
1)Polymorphism
(only static or compile time)
2) Abstraction VS interface
3) Exception Handling
Workshop Day 3, Part 3
Thank you very much to stay with me!

More Related Content

Similar to Object-oriented programming 3.pptx

Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
Krishnaov
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
Muhammad Younis
 
Understanding class, object & interface
Understanding class, object & interfaceUnderstanding class, object & interface
Understanding class, object & interface
MD. Shohag Mia
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
Dr.Neeraj Kumar Pandey
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
Ajay Chimmani
 
Java basics
Java basicsJava basics
Java basics
Shivanshu Purwar
 
Oopsinphp
OopsinphpOopsinphp
Oopsinphp
NithyaNithyav
 
C#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developersC#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developers
Sanjaya Prakash Pradhan
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
Eng Teong Cheah
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
AnkurSingh340457
 
C++ Object Oriented Programming
C++  Object Oriented ProgrammingC++  Object Oriented Programming
C++ Object Oriented Programming
Gamindu Udayanga
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rdConnex
 
Lesson 13 object and class
Lesson 13 object and classLesson 13 object and class
Lesson 13 object and class
MLG College of Learning, Inc
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
Medhat Dawoud
 

Similar to Object-oriented programming 3.pptx (20)

Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Object Oriented Programming C#
Object Oriented Programming C#Object Oriented Programming C#
Object Oriented Programming C#
 
Understanding class, object & interface
Understanding class, object & interfaceUnderstanding class, object & interface
Understanding class, object & interface
 
Classes2
Classes2Classes2
Classes2
 
Object-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modulesObject-oriented programming (OOP) with Complete understanding modules
Object-oriented programming (OOP) with Complete understanding modules
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
Java basics
Java basicsJava basics
Java basics
 
Oopsinphp
OopsinphpOopsinphp
Oopsinphp
 
C#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developersC#.net interview questions for dynamics 365 ce crm developers
C#.net interview questions for dynamics 365 ce crm developers
 
Core java questions
Core java questionsCore java questions
Core java questions
 
Learn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & InheritanceLearn C# Programming - Classes & Inheritance
Learn C# Programming - Classes & Inheritance
 
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
C++ Object Oriented Programming
C++  Object Oriented ProgrammingC++  Object Oriented Programming
C++ Object Oriented Programming
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rd
 
Lesson 13 object and class
Lesson 13 object and classLesson 13 object and class
Lesson 13 object and class
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
Csci360 20 (1)
Csci360 20 (1)Csci360 20 (1)
Csci360 20 (1)
 
Csci360 20
Csci360 20Csci360 20
Csci360 20
 
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
 

Recently uploaded

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 

Recently uploaded (20)

Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

Object-oriented programming 3.pptx

  • 1. Workshop on Object-oriented programming FAHAD HUSSAIN MCS, MSCS, DAE(CIT) Computer Science Instructor of well known international Center Also, Machine Learning and Deep learning Practitioner For further assistance, code and slide https://fahadhussaincs.blogspot.com/
  • 2. Object-oriented programming For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data, in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods). It is the programming concept based on bottom-up approach! The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
  • 3. Object-oriented programming For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Pillars of object-oriented programming 1)Encapsulation: 2)Inheritance: 3)Polymorphism: 4)Abstraction: 5)*Exception Handling
  • 4. Class ,Object and Function/Method For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Before going into depth in OOP, let’s understand the 6 basic things! 1. What is class 2. What is object 3. What is namespaces 4. What is function/Method 5. What is Constructor and its types 6. What is Destructors
  • 5. Class ,Object and Function/Method For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Class: It is a user-defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. A class is like a blueprint for an object. In simple words, it is a prototype or building block structure for starting work in the OOP approach! Object: An Object is an identifiable entity with some characteristics and behavior. An Object is an instance of a Class. When a class is defined, no memory is allocated but when it is instantiated (i.e. an object is created) memory is allocated.
  • 6. Class ,Object and Function/Method For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Function VS Method: A method is a code block that contains a series of statements according to the requirement of the program! In OOP = Method and in procedure = Function Namespaces Namespaces in C# are used to organize too many classes so that it can be easy to handle the application. We use System.Console where System is the namespace and Console is the class. To access the class of a namespace, we need to use namespacename.classname. We can use using keyword so that we don't have to use complete name all the time.
  • 7. Constructor and its types For further assistance, code and slide https://fahadhussaincs.blogspot.com/ A constructor is a special method of the class which gets automatically invoked whenever an instance of the class is created. Like methods, a constructor also contains the collection of instructions that are executed at the time of Object creation. It is used to assign initial values to the data members of the same class. Types of Constructor • Default Constructor • Parametrized Constructor (with overload concept) • Copy Constructor • Private Constructor • Static Constructor
  • 8. Constructor and its types For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Default Constructor A constructor with no parameters is called a default constructor. A default constructor has every instance of the class to be initialized to the same values. The default constructor initializes all numeric fields to zero and all string and object fields to null inside a class.
  • 9. Constructor and its types For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Parameterized Constructor with overload A constructor have at least one parameter is called a parametrized constructor. It can initialize each instance of the class to different values.
  • 10. Constructor and its types For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Copy Constructor This constructor will creates an object by copying variables from another object. Its main use is to initialize a new instance to the values of an existing instance.
  • 11. Constructor and its types For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Private Constructor If a constructor is created with private specifier is known as Private Constructor. It is not possible for other classes to derive from this class and also it’s not possible to create an instance of this class. Points To Remember : use private constructor when we have only static members. Using private constructor, prevents the creation of the instances of that class.
  • 12. Constructor and its types For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Static Constructor (no access modifier, no parameters) Static Constructor has to be invoked only once in the class and it has been invoked during the creation of the first reference to a static member in the class. A static constructor is initialized static fields or data of the class and to be executed only once. Points To Remember : It can’t be called directly. When it is executing then the user has no control. It does not take access modifiers or any parameters. It is called automatically to initialize the class before the first instance created.
  • 13. Constructor For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Important points to Remember About Constructors • Constructor of a class must have the same name as the class name in which it resides. • A constructor can not be abstract, final, and Synchronized. • Within a class, you can create only one static constructor. • A constructor doesn’t have any return type, not even void. • A static constructor cannot be a parameterized constructor. • A class can have any number of constructors. • Access modifiers can be used in constructor declaration to control its access i.e. which other class can call the constructor.
  • 14. Destructors For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Destructors in C# are methods inside the class used to destroy instances of that class when they are no longer needed. The Destructor is called implicitly by the .NET Framework's Garbage collector and therefore programmer has no control as when to invoke the destructor • In c#, destructors can be used only in classes and a class can contain only one destructor. • The destructor in class can be represented by using tilde (~) operator • The destructor in c# won’t accept any parameters and access modifiers. • The destructor will invoke automatically, whenever an instance of class is no longer needed. • The destructor automatically invoked by garbage collector whenever the class objects that are no longer needed in application.
  • 15. Till Now, We have Learn! For further assistance, code and slide https://fahadhussaincs.blogspot.com/ What is class What is object What is namespaces What is function/Method What is Constructor and its types What is Destructor Theory + Practical in C#, Thank you Very Much, end of Workshop Part 1 Now, next we will discuss about the pillars from scratch!
  • 16. Workshop on Object-oriented programming FAHAD HUSSAIN MCS, MSCS, DAE(CIT) Computer Science Instructor of well known international Center Also, Machine Learning and Deep learning Practitioner For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Workshop Part 2
  • 17. Till Now, We have Learn! For further assistance, code and slide https://fahadhussaincs.blogspot.com/ What is class What is object What is namespaces What is function/Method What is Constructor and its types What is Destructor Workshop Part 1
  • 18. Object-oriented programming For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Pillars of object-oriented programming 1)Encapsulation: 2)Inheritance: 3)Polymorphism: 4)Abstraction: 5)*Exception Handling
  • 19. Encapsulation For further assistance, code and slide https://fahadhussaincs.blogspot.com/ In object-oriented programming, encapsulation refers to the bundling of data with the methods that operate on that data, or the restricting of direct access to some of an object's components. Encapsulation, its can be accessed/done by Access Modifier / Access Specifier
  • 20. For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Access modifiers (or access specifiers) are keywords in object-oriented languages that set the accessibility of classes, methods, and other members. Access modifiers are a specific part of programming language syntax used to facilitate the encapsulation of components. In the C#, there are Six access Modifier whereas just for information 4 in Java! 1. Public: The type or member can be accessed by any other code in the same assembly or another assembly that references it. 2. Private: The type or member can be accessed only by code in the same class or struct. 3. Protected: The type or member can be accessed only by code in the same class, or in a class that is derived from that class. 4. Internal : The type or member can be accessed by any code in the same assembly, but not from another assembly. 5. Protected Internal : The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. 6. Private Protected: It access modifier is a combination of the private and protected keywords. We can access members inside the containing class or in a class that derives from a containing class, but only in the same assembly(project). Therefore, if we try to access it from another assembly, we will get an error. (C# 7.0) In Java Public Private Protected Default
  • 21. Inheritance For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Object-Oriented programming language is code reuse. This reusability is possible due to the relationship b/w the classes. Object oriented programming generally support 4 types of relationships that are: inheritance , association, composition and aggregation. All these relationship is based on "is a" relationship, "has-a" relationship and "part-of" relationship.
  • 22. Inheritance For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Also, multiple and hybrid level, (preform by interface) because in C#, and Java these are not allowed using inheritance!
  • 23. For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Has a relationship: Association is relation between two separate classes which establishes through their Objects. Association can be one-to-one, one-to-many, many-to-one, many-to- many. In Object-Oriented programming, an Object communicates to other Object to use functionality and services provided by that object. Composition and Aggregation are the two forms of association. Student has a ID, name etc… also with new keyword!
  • 24. Polymorphism For further assistance, code and slide https://fahadhussaincs.blogspot.com/ The word polymorphism means having many forms. In object-oriented programming paradigm, polymorphism is often expressed as 'one interface, multiple functions’.
  • 25. Polymorphism For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Function Overloading You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type.
  • 26. Polymorphism For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Operator overloading: The concept of overloading a function can also be applied to operators. Operator overloading gives the ability to use the same operator to do various operations. Let’s understand the concept of + in the code…
  • 27. Till Now, We have Learn! For further assistance, code and slide https://fahadhussaincs.blogspot.com/ 1)What is Encapsulation: 2)Inheritance: 3)Polymorphism (only static or compile time) Theory + Practical in C#, Thank you Very Much, end of Workshop Part 2 Now, next we will discuss about the pillars (rest of the) from scratch in the Last Session (Part 3)!
  • 28. Workshop on Object-oriented programming FAHAD HUSSAIN MCS, MSCS, DAE(CIT) Computer Science Instructor of well known international Center Also, Machine Learning and Deep learning Practitioner For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Workshop Part 3
  • 29. Till Now, We have Learn! For further assistance, code and slide https://fahadhussaincs.blogspot.com/ What is class What is object What is namespaces What is function/Method What is Constructor and its types What is Destructor Workshop Part 1 1)What is Encapsulation: 2)Inheritance: 3)Polymorphism (only static or compile time) Workshop Part 2
  • 30. Polymorphism For further assistance, code and slide https://fahadhussaincs.blogspot.com/ The word polymorphism means having many forms. In object-oriented programming paradigm, polymorphism is often expressed as 'one interface, multiple functions’. Method Override … Method Hiding
  • 31. Polymorphism For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Method Hiding: For hiding the base class method from derived class simply declare the derived class method with the new keyword.
  • 32. Method Overriding For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Run Time Polymorphism means overriding a base class method in derived class by creating a similar function and this can be achieved by using override & virtual keywords along with inheritance principle. By using run time polymorphism, we can override a base class method in derived class by creating a method with same name and parameters to perform a different task. In c#, the run time polymorphism can be achieved by using method overriding and it is also called as late binding or dynamic binding.
  • 33. Abstraction For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Abstraction is the detail hiding of (implementation hiding). Abstraction will be done by: Abstract class • By using Abstraction you can used abstraction 0 to 100%!!!
  • 34. Abstraction For further assistance, code and slide https://fahadhussaincs.blogspot.com/ Interface (It is special type of class but not exactly class, containing the abstract method only) also used for multiple inheritance in C#. • By using Interface you can used abstraction 100%!!! • Also, Interface used for multiple level inheritance in C#, Java!
  • 35. Exception Handling For further assistance, code and slide https://fahadhussaincs.blogspot.com/  try – A try block is used to encapsulate a region of code. If any code throws an exception within that try block, the exception will be handled by the corresponding catch.  catch – When an exception occurs, the Catch block of code is executed. This is where you are able to handle the exception, log it, or ignore it.  finally – The finally block allows you to execute certain code if an exception is thrown or not. For example, disposing of an object that must be disposed of.  throw – The throw keyword is used to actually create a new exception that is the bubbled up to a try catch finally block. The try catch and finally block is a mechanism to detect and handle run-time errors in code. It is provided by one of the built-in classes for common exceptions. The exceptions are anomalies that occur during the execution of a program. They can be because of user, logic or system errors. If a user (programmer) does not provide a mechanism to handle these anomalies, the compiler provide a default mechanism, which terminates the program execution.
  • 36. Finally For further assistance, code and slide https://fahadhussaincs.blogspot.com/ What is class What is object What is namespaces What is function/Method What is Constructor and its types What is Destructor Workshop Day 1, Part 1 1)What is Encapsulation: 2)Inheritance: 3)Polymorphism (only static or compile time) Workshop Day 2, Part 2 1)Polymorphism (only static or compile time) 2) Abstraction VS interface 3) Exception Handling Workshop Day 3, Part 3 Thank you very much to stay with me!