SlideShare a Scribd company logo
1 of 29
Object Based Programming
May 2015
Summary Slide
• Instantiating An Object
• Encapsulation
• Inheritance
• Polymorphism
▫ Overriding Methods
▫ Overloading vs. Overriding
• Implementing a Time Abstract Data type with a Class
▫ Controlling Access to Members
▫ Initializing Class Objects: Constructors
▫ Properties
▫ Composition
▫ Shared Class Members
▫ Const and ReadOnly Members
• Garbage Collection
Object Terminology Review
• Object - like a noun, a thing
▫ Buttons, Text Boxes, Labels
• Properties - like an adjective, characteristics of object
▫ Text, ForeColor, Checked, Visible, Enabled
• Methods - like a verb, an action or behavior, something the
object can do or have done to it
▫ ShowDialog, Focus, Clear, ToUpper, ToLower
• Events - object response to user action or other events
▫ Click, Enter, Activate
Instantiating An Object
• Creating a new object based on a class
• Create an instance of the class by using the
New keyword and specify the class
Encapsulation
Sometimes referred to as data hiding;an
object can expose only those data
elements and procedures that it wishes
Inheritance
• Inheritance is a form of reusability in which classes
are created by absorbing an existing class’s data and
behaviors and improving by adding new capabilities.
• Inheritance allows a software developer to derive a
new class from an existing one
• The existing class is called the parent class, or
superclass, or base class
• The derived class is called the child class or
subclass.
• As the name implies, the child inherits
characteristics of the parent
6
Inheritance
7
Deriving Subclasses
• In VB.NET, we use the reserved word Inherits
to establish an inheritance relationship
8
Controlling Inheritance
• Visibility modifiers determine which class
members get inherited and which do not
• Variables and methods declared with public
visibility are inherited, and those with private
visibility are not
• But public variables violate our goal of
encapsulation
• There are two more visibility modifiers that
helps in inheritance situations: Protected and
Friend
9
The Protected Modifier
• The Protected visibility modifier allows a
member of a base class to be inherited into the
child
• But Protected visibility provides more
encapsulation than public does
• However, Protected visibility is not as tightly
encapsulated as Private visibility
10
The Friend Modifier
• The Friend visibility modifier allows a member
of a base class to be inherited into the child only
if the the derived class is in the same assembly
11
The MyBase Reference
12
Single vs. Multiple Inheritance
• VB.NET supports single inheritance, meaning that a
derived class can have only one parent class
• Multiple inheritance allows a class to be derived from
two or more classes, inheriting the members of all
parents
• Collisions, such as the same variable name in two
parents, have to be resolved
• In most cases, the use of interfaces gives us the best
aspects of multiple inheritance without the overhead
Polymorphism
• Different classes of objects may have behaviors
that are named the same but are implemented
differently
• Programmers can request an action without
knowing exactly what kind of object they have or
exactly how it will carry out the action
Polymorphism Implemented
• Overloading
▫ Argument type determines which version of a
method is used
▫ Example: MessageBox.Show method
• Overriding
▫ Refers to a class that has the same method name
as its base class
▫ Method in subclass takes precedence
Overriding Methods
• A child class can override the definition of an
inherited method in favor of its own
• That is, a child can redefine a method that it
inherits from its parent
• The new method must have the same
signature as the parent's method, but can
have different code in the body
16
Overloading vs. Overriding
• Don't confuse the concepts of overloading and
overriding
• Overloading deals with multiple methods in the same
class with the same name but different signatures
• Overriding deals with two methods, one in a parent
class and one in a child class, that have the same
signature
17
Reusability
• The main purpose behind OOOP and
Inheritance in particular
• New classes created with Class Module can be
used in multiple projects
• Each object created from the class can have its
own properties
Multitier Applications
• Common use of classes is to create multitier
applications
• Each of the functions of a multitier application
can be coded in a separate component and
stored and run on different machines
• Goal is to create components that can be
combined and replaced
Three-tier Model
• Most common implementation of multitier
Presentation Tier Business Tier Data Tier
User Interface
Forms
Controls
Menus
Business Objects
Validation
Calculations
Business Logic
Business Rates
Data Retrieval
Data Storage
Implementing a Time Abstract Data
type with a Class
• VB programmers concentrate on creating
their own user-defined types called classes
(also referred as programmer defined types)
• Classes in VB facilitate the creation of special
data types, called abstract data types (ADT)
Class Scope
• A class’s instance variables and methods belong
to the class’s scope.
• Class members that are visible can be accessed
only through a “handle”
(ObjectReferenceName.memberName)
• Variables within methods
▫ Only methods can access that variable
• Keyword Me is a hidden instance variable can be
accessed in a method by preceding its name with
the keyword Me and dot operator
Controlling Access to Members
• The member access modifiers Public, Private,
Protected, and Friend control access to a class’s
instance variables and methods.
• Control access to a class’s instance variables and
methods
▫ Public: Serves primarily to present interfaces of a
class
▫ Private: Holds clients private data safely
▫ Get and set functions have ability to access private
data
Initializing Class Objects: Constructors
• A constructor method initializes its class’s members
• When appropriate, provide a default constructor to
ensure that every object is initialized with
meaningful values
• Parametized constructors have arguments
• If a class does not have a defined constructor, the
compiler will create an empty constructor.
• If an instance variable is not initialized the compiler
will assign a default value
• Overloaded Constructors must have different
numbers and/or types and/or orders of parameters
Properties
• Methods in a class can manipulate the class’s
Private instance variables. Public methods allow
other object to change a class’s properties.
• Get accessor
▫ In Visual Basic instance variables as private does
not guarantee data integrity
• Set accessor
▫ Cannot return values indicating a failed attempt to
assign invalid data to objects of the class
▫ Control the setting of instance variables to valid
values
• Get and Set accessors are not required
• A property with only Get accessor is called
ReadOnly
• A property with only Set accessor is called
WriteOnly
• After we define a property, we can use it in the
same way as we use a variable.
Using the Me Reference
Shared Class Members
• Contains only one copy of this variable in memory
• When a single copy of the data will suffice, use
Shared class variables to save storage.
• Shared class variables are not the same as global
variables because Shared class variables have class
scope
• A class’s shared class members are available as soon
as the class is loaded into memory at execution time
• Shared method has no Me reference
• A shared method cannot access non-shared class
members.
Const and ReadOnly Members
Garbage Collection
• Resource leaks
▫ Objects must have an efficient way to return memory and release resources
when the program no longer uses those objects
• Memory leaks
▫ In Visual Basic memory is reclaimed automatically, hence it experiences rare
memory leaks as compared to C and C++
• Finalization
▫ Finalizer method performs termination housekeeping on that object just
before the garbage collector reclaims the object's memory.
• Feature of .NET Common Language Runtime (CLR) that cleans up
unused components
• Periodically checks for unreferenced objects and releases all memory
and system resources used by the objects
• Microsoft recommends depending on Garbage Collection rather than
Finalize procedures

More Related Content

What's hot

Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentalsAnsgarMary
 
Intro to java programming
Intro to java programmingIntro to java programming
Intro to java programmingLeah Stephens
 
Object oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented conceptsObject oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented conceptsVaibhav Khanna
 
Operationalizing security data science for the cloud: Challenges, solutions, ...
Operationalizing security data science for the cloud: Challenges, solutions, ...Operationalizing security data science for the cloud: Challenges, solutions, ...
Operationalizing security data science for the cloud: Challenges, solutions, ...Ram Shankar Siva Kumar
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaiUnmesh Baile
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programmingSachin Sharma
 

What's hot (16)

Chapter3 bag2
Chapter3 bag2Chapter3 bag2
Chapter3 bag2
 
Introduction to oop and java fundamentals
Introduction to oop and java fundamentalsIntroduction to oop and java fundamentals
Introduction to oop and java fundamentals
 
Java introduction
Java introductionJava introduction
Java introduction
 
Intro to java programming
Intro to java programmingIntro to java programming
Intro to java programming
 
Object oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented conceptsObject oriented programming 3 object oriented concepts
Object oriented programming 3 object oriented concepts
 
Oops (inheritance&interface)
Oops (inheritance&interface)Oops (inheritance&interface)
Oops (inheritance&interface)
 
Pj01 x-classes and objects
Pj01 x-classes and objectsPj01 x-classes and objects
Pj01 x-classes and objects
 
RIBBUN SOFTWARE
RIBBUN SOFTWARERIBBUN SOFTWARE
RIBBUN SOFTWARE
 
Introduction what is java
Introduction what is javaIntroduction what is java
Introduction what is java
 
Operationalizing security data science for the cloud: Challenges, solutions, ...
Operationalizing security data science for the cloud: Challenges, solutions, ...Operationalizing security data science for the cloud: Challenges, solutions, ...
Operationalizing security data science for the cloud: Challenges, solutions, ...
 
Chap01
Chap01Chap01
Chap01
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
Java
JavaJava
Java
 
Ch5 inheritance
Ch5 inheritanceCh5 inheritance
Ch5 inheritance
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
Java01
Java01Java01
Java01
 

Viewers also liked (16)

JULIANA_BACCHUS_RESUME 2015
JULIANA_BACCHUS_RESUME 2015JULIANA_BACCHUS_RESUME 2015
JULIANA_BACCHUS_RESUME 2015
 
Lady Tello
Lady TelloLady Tello
Lady Tello
 
Deepdive presentation GBAF20 primary care
Deepdive presentation GBAF20 primary careDeepdive presentation GBAF20 primary care
Deepdive presentation GBAF20 primary care
 
Protect your rights with credit sweep
Protect your rights with credit sweepProtect your rights with credit sweep
Protect your rights with credit sweep
 
Manuel atelier iveco 4 x4 - véhicule de 1998 - PDF
Manuel atelier iveco 4 x4 - véhicule de 1998 - PDFManuel atelier iveco 4 x4 - véhicule de 1998 - PDF
Manuel atelier iveco 4 x4 - véhicule de 1998 - PDF
 
Tema 3 naturales
Tema 3 naturalesTema 3 naturales
Tema 3 naturales
 
portfo
portfoportfo
portfo
 
Tema 3 el sociales
Tema 3 el socialesTema 3 el sociales
Tema 3 el sociales
 
Tema 4 naturales
Tema 4 naturalesTema 4 naturales
Tema 4 naturales
 
39112 94.1307008130921Περιβάλλοντος
39112 94.1307008130921Περιβάλλοντος 39112 94.1307008130921Περιβάλλοντος
39112 94.1307008130921Περιβάλλοντος
 
Herbal Sex Medicine for Male
Herbal Sex Medicine for MaleHerbal Sex Medicine for Male
Herbal Sex Medicine for Male
 
insights_feb_2016
insights_feb_2016insights_feb_2016
insights_feb_2016
 
Plants
PlantsPlants
Plants
 
GBAF242 ECT Underlying Financial Position
GBAF242 ECT Underlying Financial PositionGBAF242 ECT Underlying Financial Position
GBAF242 ECT Underlying Financial Position
 
Comparing sql and nosql dbs
Comparing sql and nosql dbsComparing sql and nosql dbs
Comparing sql and nosql dbs
 
About GPA 2015
About GPA 2015About GPA 2015
About GPA 2015
 

Similar to Object oriented programming

Chapter08 - Inheritance.ppt
Chapter08 - Inheritance.pptChapter08 - Inheritance.ppt
Chapter08 - Inheritance.pptPatrick Okot
 
Questpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPSQuestpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPSgdrealspace
 
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdfmarkbrianBautista
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxethiouniverse
 
SystemVerilog_Classes.pdf
SystemVerilog_Classes.pdfSystemVerilog_Classes.pdf
SystemVerilog_Classes.pdfssusere9cd04
 
Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with javaSujit Kumar
 
chapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programmingchapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programmingWondimuBantihun1
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - EncapsulationMichael Heron
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP conceptsAhmed Farag
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingRatnaJava
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
 
CPP14 - Encapsulation
CPP14 - EncapsulationCPP14 - Encapsulation
CPP14 - EncapsulationMichael Heron
 
Web Design & Development - Session 9
Web Design & Development - Session 9Web Design & Development - Session 9
Web Design & Development - Session 9Shahrzad Peyman
 

Similar to Object oriented programming (20)

OOPS Characteristics
OOPS CharacteristicsOOPS Characteristics
OOPS Characteristics
 
Chapter08 - Inheritance.ppt
Chapter08 - Inheritance.pptChapter08 - Inheritance.ppt
Chapter08 - Inheritance.ppt
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Questpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPSQuestpond - Top 10 Interview Questions and Answers on OOPS
Questpond - Top 10 Interview Questions and Answers on OOPS
 
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf04_-_Inheritance_Polymorphism_and_Interfaces.pdf
04_-_Inheritance_Polymorphism_and_Interfaces.pdf
 
Object Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptxObject Oriented Programming Tutorial.pptx
Object Oriented Programming Tutorial.pptx
 
SystemVerilog_Classes.pdf
SystemVerilog_Classes.pdfSystemVerilog_Classes.pdf
SystemVerilog_Classes.pdf
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
Introduction to OOP with java
Introduction to OOP with javaIntroduction to OOP with java
Introduction to OOP with java
 
chapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programmingchapter 5 concepts of object oriented programming
chapter 5 concepts of object oriented programming
 
2CPP09 - Encapsulation
2CPP09 - Encapsulation2CPP09 - Encapsulation
2CPP09 - Encapsulation
 
Introduction to OOP concepts
Introduction to OOP conceptsIntroduction to OOP concepts
Introduction to OOP concepts
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects[OOP - Lec 06] Classes and Objects
[OOP - Lec 06] Classes and Objects
 
OCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference CardOCP Java (OCPJP) 8 Exam Quick Reference Card
OCP Java (OCPJP) 8 Exam Quick Reference Card
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
CPP14 - Encapsulation
CPP14 - EncapsulationCPP14 - Encapsulation
CPP14 - Encapsulation
 
Web Design & Development - Session 9
Web Design & Development - Session 9Web Design & Development - Session 9
Web Design & Development - Session 9
 

Recently uploaded

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 

Recently uploaded (20)

Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 

Object oriented programming

  • 2. Summary Slide • Instantiating An Object • Encapsulation • Inheritance • Polymorphism ▫ Overriding Methods ▫ Overloading vs. Overriding • Implementing a Time Abstract Data type with a Class ▫ Controlling Access to Members ▫ Initializing Class Objects: Constructors ▫ Properties ▫ Composition ▫ Shared Class Members ▫ Const and ReadOnly Members • Garbage Collection
  • 3. Object Terminology Review • Object - like a noun, a thing ▫ Buttons, Text Boxes, Labels • Properties - like an adjective, characteristics of object ▫ Text, ForeColor, Checked, Visible, Enabled • Methods - like a verb, an action or behavior, something the object can do or have done to it ▫ ShowDialog, Focus, Clear, ToUpper, ToLower • Events - object response to user action or other events ▫ Click, Enter, Activate
  • 4. Instantiating An Object • Creating a new object based on a class • Create an instance of the class by using the New keyword and specify the class
  • 5. Encapsulation Sometimes referred to as data hiding;an object can expose only those data elements and procedures that it wishes
  • 6. Inheritance • Inheritance is a form of reusability in which classes are created by absorbing an existing class’s data and behaviors and improving by adding new capabilities. • Inheritance allows a software developer to derive a new class from an existing one • The existing class is called the parent class, or superclass, or base class • The derived class is called the child class or subclass. • As the name implies, the child inherits characteristics of the parent 6
  • 8. Deriving Subclasses • In VB.NET, we use the reserved word Inherits to establish an inheritance relationship 8
  • 9. Controlling Inheritance • Visibility modifiers determine which class members get inherited and which do not • Variables and methods declared with public visibility are inherited, and those with private visibility are not • But public variables violate our goal of encapsulation • There are two more visibility modifiers that helps in inheritance situations: Protected and Friend 9
  • 10. The Protected Modifier • The Protected visibility modifier allows a member of a base class to be inherited into the child • But Protected visibility provides more encapsulation than public does • However, Protected visibility is not as tightly encapsulated as Private visibility 10
  • 11. The Friend Modifier • The Friend visibility modifier allows a member of a base class to be inherited into the child only if the the derived class is in the same assembly 11
  • 13. Single vs. Multiple Inheritance • VB.NET supports single inheritance, meaning that a derived class can have only one parent class • Multiple inheritance allows a class to be derived from two or more classes, inheriting the members of all parents • Collisions, such as the same variable name in two parents, have to be resolved • In most cases, the use of interfaces gives us the best aspects of multiple inheritance without the overhead
  • 14. Polymorphism • Different classes of objects may have behaviors that are named the same but are implemented differently • Programmers can request an action without knowing exactly what kind of object they have or exactly how it will carry out the action
  • 15. Polymorphism Implemented • Overloading ▫ Argument type determines which version of a method is used ▫ Example: MessageBox.Show method • Overriding ▫ Refers to a class that has the same method name as its base class ▫ Method in subclass takes precedence
  • 16. Overriding Methods • A child class can override the definition of an inherited method in favor of its own • That is, a child can redefine a method that it inherits from its parent • The new method must have the same signature as the parent's method, but can have different code in the body 16
  • 17. Overloading vs. Overriding • Don't confuse the concepts of overloading and overriding • Overloading deals with multiple methods in the same class with the same name but different signatures • Overriding deals with two methods, one in a parent class and one in a child class, that have the same signature 17
  • 18. Reusability • The main purpose behind OOOP and Inheritance in particular • New classes created with Class Module can be used in multiple projects • Each object created from the class can have its own properties
  • 19. Multitier Applications • Common use of classes is to create multitier applications • Each of the functions of a multitier application can be coded in a separate component and stored and run on different machines • Goal is to create components that can be combined and replaced
  • 20. Three-tier Model • Most common implementation of multitier Presentation Tier Business Tier Data Tier User Interface Forms Controls Menus Business Objects Validation Calculations Business Logic Business Rates Data Retrieval Data Storage
  • 21. Implementing a Time Abstract Data type with a Class • VB programmers concentrate on creating their own user-defined types called classes (also referred as programmer defined types) • Classes in VB facilitate the creation of special data types, called abstract data types (ADT)
  • 22. Class Scope • A class’s instance variables and methods belong to the class’s scope. • Class members that are visible can be accessed only through a “handle” (ObjectReferenceName.memberName) • Variables within methods ▫ Only methods can access that variable • Keyword Me is a hidden instance variable can be accessed in a method by preceding its name with the keyword Me and dot operator
  • 23. Controlling Access to Members • The member access modifiers Public, Private, Protected, and Friend control access to a class’s instance variables and methods. • Control access to a class’s instance variables and methods ▫ Public: Serves primarily to present interfaces of a class ▫ Private: Holds clients private data safely ▫ Get and set functions have ability to access private data
  • 24. Initializing Class Objects: Constructors • A constructor method initializes its class’s members • When appropriate, provide a default constructor to ensure that every object is initialized with meaningful values • Parametized constructors have arguments • If a class does not have a defined constructor, the compiler will create an empty constructor. • If an instance variable is not initialized the compiler will assign a default value • Overloaded Constructors must have different numbers and/or types and/or orders of parameters
  • 25. Properties • Methods in a class can manipulate the class’s Private instance variables. Public methods allow other object to change a class’s properties. • Get accessor ▫ In Visual Basic instance variables as private does not guarantee data integrity • Set accessor ▫ Cannot return values indicating a failed attempt to assign invalid data to objects of the class ▫ Control the setting of instance variables to valid values • Get and Set accessors are not required • A property with only Get accessor is called ReadOnly • A property with only Set accessor is called WriteOnly • After we define a property, we can use it in the same way as we use a variable.
  • 26. Using the Me Reference
  • 27. Shared Class Members • Contains only one copy of this variable in memory • When a single copy of the data will suffice, use Shared class variables to save storage. • Shared class variables are not the same as global variables because Shared class variables have class scope • A class’s shared class members are available as soon as the class is loaded into memory at execution time • Shared method has no Me reference • A shared method cannot access non-shared class members.
  • 29. Garbage Collection • Resource leaks ▫ Objects must have an efficient way to return memory and release resources when the program no longer uses those objects • Memory leaks ▫ In Visual Basic memory is reclaimed automatically, hence it experiences rare memory leaks as compared to C and C++ • Finalization ▫ Finalizer method performs termination housekeeping on that object just before the garbage collector reclaims the object's memory. • Feature of .NET Common Language Runtime (CLR) that cleans up unused components • Periodically checks for unreferenced objects and releases all memory and system resources used by the objects • Microsoft recommends depending on Garbage Collection rather than Finalize procedures