Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
Co-presented with Jens Augustini
Object Oriented Programming (OOP) may drastically reduce your coding time in projects that reach a higher degree of complexity, as it brings re-usable and consistent logic in the form of your own objects to your fingertips. This session will show how to create and use your own classes and how they can relate to the LotusScript Object Model. If you are familiar with LotusScript but don't know how to create your own classes, this session is for you!
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptBill Buchan
This session starts where the introductory Object Oriented Programming for LotusScript session stops. We'll show advanced encapsulation and inheritance, and demonstrates best practice code reuse with Object Oriented Programming techniques.You'll leave with a fully functional IBM Lotus Notes application containing enterprise features such as error trapping, log levels, code reuse and a far greater understanding of Object Oriented Programming methodology within LotusScript.
Lotusphere 2007 AD507 Leveraging the Power of Object Oriented Programming in ...Bill Buchan
Co-presented with Jens Augustini
Object Oriented Programming (OOP) may drastically reduce your coding time in projects that reach a higher degree of complexity, as it brings re-usable and consistent logic in the form of your own objects to your fingertips. This session will show how to create and use your own classes and how they can relate to the LotusScript Object Model. If you are familiar with LotusScript but don't know how to create your own classes, this session is for you!
Lotusphere 2007 BP301 Advanced Object Oriented Programming for LotusScriptBill Buchan
This session starts where the introductory Object Oriented Programming for LotusScript session stops. We'll show advanced encapsulation and inheritance, and demonstrates best practice code reuse with Object Oriented Programming techniques.You'll leave with a fully functional IBM Lotus Notes application containing enterprise features such as error trapping, log levels, code reuse and a far greater understanding of Object Oriented Programming methodology within LotusScript.
Presentation I gave at the Berkeley Drupal Users Group on February 27, 2012 covering entities in Drupal 7 including entity types, bundles, fields, nodes, the Entity API and the Schema API. I use TextbookMadness.com as an example of how to leverage entities.
Click on my name to find a newer (better!) version of these slides.
JAVA design patterns and Basic OOp conceptsRahul Malhotra
This Presentation is about java design patterns. I have covered some OOPs concepts as well: Polymorphism, Interface, Inheritance, abstraction etc. And the Main Topic Covers: Factory Design Patterns,Observer Design Patterns,Proxy Design Patterns,Adapter Design Patterns,MVC Design Patterns etc
Presentation about working with the Activity Stream in IBM Connections 4+ meaning what the concepts behind the Activity Stream are, who to work with it and how to perform many of the tasks you would need to do such as marking/unmarking as actionable etc.
Mikkel Heisterberg - An introduction to developing for the Activity StreamLetsConnect
The future of business is social and the activity stream is the way events and messages are communicated in the social business. In this session you’ll learn all there is to know about the activity stream including exactly what it is and how to interact with it using your favorite development environment whether that be JavaScript, XPages, Java or even the plain vanilla HTTP based REST API. This session is for you if you want to start working the Activity Stream.
C++ is an enhanced version of the C language. C++ includes everything that is part of C language and adds support for object oriented programming (OOP). With very few, very major exceptions, C++ is a superset of C
Presentation I gave at the Berkeley Drupal Users Group on February 27, 2012 covering entities in Drupal 7 including entity types, bundles, fields, nodes, the Entity API and the Schema API. I use TextbookMadness.com as an example of how to leverage entities.
Click on my name to find a newer (better!) version of these slides.
JAVA design patterns and Basic OOp conceptsRahul Malhotra
This Presentation is about java design patterns. I have covered some OOPs concepts as well: Polymorphism, Interface, Inheritance, abstraction etc. And the Main Topic Covers: Factory Design Patterns,Observer Design Patterns,Proxy Design Patterns,Adapter Design Patterns,MVC Design Patterns etc
Presentation about working with the Activity Stream in IBM Connections 4+ meaning what the concepts behind the Activity Stream are, who to work with it and how to perform many of the tasks you would need to do such as marking/unmarking as actionable etc.
Mikkel Heisterberg - An introduction to developing for the Activity StreamLetsConnect
The future of business is social and the activity stream is the way events and messages are communicated in the social business. In this session you’ll learn all there is to know about the activity stream including exactly what it is and how to interact with it using your favorite development environment whether that be JavaScript, XPages, Java or even the plain vanilla HTTP based REST API. This session is for you if you want to start working the Activity Stream.
C++ is an enhanced version of the C language. C++ includes everything that is part of C language and adds support for object oriented programming (OOP). With very few, very major exceptions, C++ is a superset of C
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
About
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Technical Specifications
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
Key Features
Indigenized remote control interface card suitable for MAFI system CCR equipment. Compatible for IDM8000 CCR. Backplane mounted serial and TCP/Ethernet communication module for CCR remote access. IDM 8000 CCR remote control on serial and TCP protocol.
• Remote control: Parallel or serial interface
• Compatible with MAFI CCR system
• Copatiable with IDM8000 CCR
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
Application
• Remote control: Parallel or serial interface.
• Compatible with MAFI CCR system.
• Compatible with IDM8000 CCR.
• Compatible with Backplane mount serial communication.
• Compatible with commercial and Defence aviation CCR system.
• Remote control system for accessing CCR and allied system over serial or TCP.
• Indigenized local Support/presence in India.
• Easy in configuration using DIP switches.
Saudi Arabia stands as a titan in the global energy landscape, renowned for its abundant oil and gas resources. It's the largest exporter of petroleum and holds some of the world's most significant reserves. Let's delve into the top 10 oil and gas projects shaping Saudi Arabia's energy future in 2024.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
OOP programming for engineering students
1. Principles of Object Oriented
Programming (OOP)
Presentation
On
By
Mr. Shibdas Dutta
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
2. 2
Topics to be Covered
• Overview of OOP
• Concepts of OOP
• Principles of OOP
• Why OOP
• Relationships in OOP
• Conclusions
• Questions
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
3. 3
Overview of OOP
OOP has roots from 1960s when h/w & s/w became
increasingly complex, and also quality often
compromised.
Uses “Object” which interacts with design applications
and programs.
Focuses on “data” rather “process”.
Programs composed of “Object” i.e. “Modules”.
Object contains all “data” to manipulate its own data
structure unlike modular programming which focused to
“function”.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
4. 4
Overview of OOP (Contd…)
Collection of “co-operating” object rather “sub-routines”.
Each object is capable of receiving messages,
processing data and sending messages to other object.
“Object” can be viewed as an independent “machine”
with distinct role.
For example: Smalltalk, Ruby, Simula, Algol, Python,
C++, Java to mention a few.
Remember, Smalltalk is the first OOP.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
5. 5
Concept Of OOP
Fundamental concepts of OOP are as follows:
Class
Object
Instance & Object State
Method
Message Passing
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
6. 6
Class
Is a “blueprint” or “factory” that describes the “nature” of
“some-thing”
“nature” – is thing’s characteristics (i.e. ‘attributes’, ‘fields’
or ‘properties’) and behaviors (i.e. ‘thing’s can do’ and
‘method/features’).
“some-thing” – is the “Object” itself.
For example: the class DOG would consists of
characteristics shared by all dogs, such as no. of legs,
color etc. and the ability to bark and sit are the behaviors.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
7. 7
Object
A pattern of a class i.e. class DOG defines all
possible dogs by listings the characteristics and
behaviors they can have.
The object Lassie is one particular dog, with
particular versions of the characteristics.
Obj1-Lassie
Obj2-Labrador
Obj3-Breeder
Class DOG
Legs
Color
Ear
Bark()
Sit()
Walk()
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
8. 8
Instance & Object State
When Object is in runtime position, is called Instance.
The Lassie object is an instance of the DOG class.
The set of all values of the attributes of a particular object
is called its “state”.
For example: Class.DOG (no_of_Legs,Color,Ear_type);
Obj1.Lassie (‘4’,”Yellow”,”Thin & Long”);
Obj2.Labrador (‘4’,”Green”,”Big”);
Obj3.Breeder (‘4’,”White”,”Very Small”);
Object State
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
9. 9
Method
An object’s ability.
For example: Lassie, being a dog, has the ability to bark,
so bark() is one of Lassie’s method.
Similarly, sit(), eat() and walk() are also methods of Lassie
object.
Generally, all behaviors of object should be represented
by methods() in program.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
10. 10
Message Passing
The process by which an object sends data to another
object or asks the other object to invoke a method.
For example: the object called Breeder may tell the
Lassie’s object to sit by passing a “SIT Down” message
which invokes Lassie’s “Sit” method.
Sit() Sit()
“SIT Down”
Obj3. Breeder Obj1. Lassie
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
11. 11
Principles of OOP
There are many opinions of what it means for a
development systems or languages to be “Object
Oriented”.
However, it is widely agree that any language that claims
to be object oriented must at least support:
Encapsulation, Data Abstraction,
Inheritance and Polymorphism.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
12. 12
Encapsulation
Is the hiding of data implementation by restricting access
to “accessor” and “mutator”.
“accessor” – is a method to “access” the data/info. of
object by using get method as following program:
( I am using VB.Net since in my opinion it is easier to read and understand positively
)
Public Class Person
Private _fullName As String = "Raymond Lewallen"
Public ReadOnly Property FullName() As String
Get
Return _fullName
End Get
End Property
End Class
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
13. 13
Encapsulation (Contd…)
“mutator” – is a public method to “modify” the data/info. of an object
using set method as following program:
Public Class Person
Private _fullName As String = "Raymond Lewallen“
Public Property FullName() As String
Get
Return FullName
End Get
Set(ByVal value As String)
_fullName = value
End Set
End Property
End Class
This type of data protection and implementation protection without breaking
the other code that is using in rest of the program, is called Encapsulation.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
14. 14
Data Abstraction
It is the simplest principle to understand.
Is the developments of classes and objects rather
implementations details.
It denotes a “model” or “view” of item (object).
It is used to manage complexity by decompose complex
system into smaller components.
Definition: “An abstraction denotes the essential
characteristics of an object that distinguish it from all
other kinds of object and thus provide defined conceptual
boundaries, relative to the perspective of the viewer”.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
15. 15
Data Abstraction (Contd…)
Public Class Person
Private _height As Int
Public Property Height() As Int
Get
Return _height
End Get
Set(ByVal Value As Int)
_height = Value
End Set
End Property
Lets, look at this code for a person object
(“height”,”weight” and “age” as attributes).
Private _weight As Int
Public Property Weight() As Int
Get
Return _weight
End Get
Set(ByVal Value As Int)
_weight = Value
End Set
End Property
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
16. 16
Data Abstraction (Contd…)
Private _age As Int
Public Property Age() As Int
Get
Return _age
End Get
Set(ByVal Value As Int)
_age = Value
End Set
End Property
Public Sub Sit()
// Code that makes the person sit
End Sub
Public Sub Run()
// Code that makes the person run
End Sub
Public Sub Cry()
// Code that make the person cry
End Sub
Public Function CanRead() As Boolean
// Code that determines if the person can read
// and returns a true or false
End Function
End Class
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
17. 17
Data Abstraction (Contd…)
So, I have create a software model of a person object.
I have created an abstract type of what a person object is to us
outside of the software world.
The abstract person is defined by the operations that can be
performed on it, and the information we can get from it and give to it.
What does the abstracted person object look like to the software
world that doesn't have access to its inner workings?
Can't really see what the code is that makes the person run!!!
So, in short, data abstraction is nothing more than the implementation of
an object that contains the same essential properties and actions, we
can find in the original object we are representing.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
18. 18
Inheritance
Objects can relate to each other with either a “has a”,
“uses a” or an “is a” relationship.
“Is a” is the inheritance way of object relationship.
For example, take a library inventory system.
Lets, A library lends Book, Magazine, Audiocassette
and Microfilm to people.
On some level, these are treated the same due to some features
should be common but are not identical because a book has an
ISBN and a magazine does not or audiocassette has a play length
where as microfilm cannot be checked out overnight!!
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
19. 19
Inheritance (Contd…)
Each of these library’s loanable assets should be represented
by its own class definition named “LibraryAsset”, called a
superclass or base class.
All assets i.e. (Book, Magazine, Audiocassette and Microfilm)
are sub classes or derived classes, so they inherit base class
characteristics.
All assets have a title, a date of acquisition, a replacement
cost and checked out or available for checked out.
Let us look at “LibraryAsset” Base class. This will be used as
the base class for Sub class “Book” :
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
20. 20
Inheritance (Contd…)
LibraryAsset { }
Title
Author
Dt._Of_acquisition
Checked_Out
ISBN
Replacement_Cost
Book { } Magazine { } Audiocassette { } Microfilm { }
Zone Play_Length Film_Color
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
21. 21
Inheritance (Contd…)
Public Class LibraryAsset
Private _title As String
Public Property Title() As String
Get
Return _title
End Get
Set(ByVal Value As String)
_title = Value
End Set
End Property
Private _checkedOut As Boolean
Public Property CheckedOut() As Boolean
Get
Return _checkedOut
End Get
Set(ByVal Value As Boolean)
_checkedOut = Value
End Set
End Property
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
22. 22
Inheritance (Contd…)
Private _dateOfAcquisition As DateTime
Public Property DateOfAcquisition() As DateTime
Get
Return _dateOfAcquisition
End Get
Set(ByVal Value As DateTime)
_dateOfAcquisition = Value
End Set
End Property
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
23. 23
Inheritance (Contd…)
Private _replacementCost As Double
Public Property ReplacementCost() As Double
Get
Return _replacementCost
End Get
Set(ByVal Value As Double)
_replacementCost = Value
End Set
End Property
End Class
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
24. 24
Inheritance (Contd…)
The inheritance relationship is called the “is a” relationship. A book
“is a” LibraryAsset, as are the other 3 assets. Lets, look at the “Book”
sub class.
Public Class Book
Inherits LibraryAsset
Private _author As String
Public Property Author() As String
Get
Return _author
End Get
Set(ByVal Value As String)
_author = Value
End Set
End Property
Private _isbn As String
Public Property Isbn() As String
Get
Return _isbn
End Get
Set(ByVal Value As String)
_isbn = Value
End Set
End Property
End Class
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
25. 25
Inheritance (Contd…)
Now, lets create an instance of the book class so we can record a
new book into the library inventory:
Dim myBook As Book = New Book
myBook.Author = "Sahil Malik"
myBook.CheckedOut = False
myBook.DateOfAcquisition = #2/15/2005#
myBook.Isbn = "0-316-63945-8"
myBook.ReplacementCost = 59.99
myBook.Title = "The Best Ado.Net Book You'll Ever Buy"
Hence, when we create a new book, we have all the properties of
the LibraryAsset class available to us as well, because we inherited
the class.
“One of the most powerful features of inheritance is the ability to
extend components without any knowledge of the way in which a
class was implemented”.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
26. 26
Polymorphism
Polymorphism means one name, many forms.
Polymorphism manifests itself by having multiple methods all with the
same name, but slighty different functionality.
There are 2 basic types of polymorphism.
Overloading, which is referred to as compile-time polymorphism.
Overridding, also called run-time polymorphism.
For method overloading, the compiler determines which method will
be executed, and this decision is made when the code gets
compiled.
For method overrriding, which method will be used, is determined at
runtime based on the dynamic type of an object.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
27. 27
Polymorphism (Contd…)
Let’s look at some code of LibraryAsset class as following:
// Base class for library assets
Public MustInherit Class LibraryAsset
// Default fine per day for overdue items
Private Const _finePerDay As Double = 1.25
// Due date for an item that has been checked out
Private _dueDate As DateTime
Public Property DueDate() As DateTime
Get
Return _dueDate
End Get
Set(ByVal Value As DateTime)
_dueDate = Value
End Set
End Property
28. 28
Polymorphism (Contd…)
// Calculates the default fine amount for an overdue item
Public Overridable Function CalculateFineTotal() As Double
Dim daysOverdue As Int = CalculateDaysOverdue()
If daysOverdue > 0 Then
Return daysOverdue * _finePerDay
Else
Return 0.0
End If
End Function
// Calculates how many days overdue for an item being returned
Protected Function CalculateDaysOverdue() As Int
Return DateDiff(DateInterval.Day, _dueDate, DateTime.Now())
End Function
End Class
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
29. 29
Polymorphism (Contd…)
// Magazine class that inherits LibraryAsset
Public NotInheritable Class Magazine Inherits LibraryAsset
// No Overriding or Overloading of any function of Base
Class in Magazine class
// So, results will come as per Base class function definition
for this Magazine class
End Class
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
30. 30
Polymorphism (Contd…)
// Book class that inherits LibraryAsset
Public NotInheritable Class Book Inherits LibraryAsset
// This is the CalculateFineTotal() function of the base class.
// This function overrides the base class function, and any call to CalculateFineTotal
from any instantiated Book class will use this function, not the base class function.
// This type of polymorphism is called overriding.
Public Overrides Function CalculateFineTotal() As Double
Dim daysOverdue As Int = CalculateDaysOverdue()
If daysOverdue > 0 Then
Return daysOverdue * 0.75
Else
Return 0.0
End If
End Function
End Class
31. 31
Polymorphism (Contd…)
// AudioCassette class that inherits LibraryAsset
Public NotInheritable Class AudioCassette Inherits LibraryAsset
// This is the CalculateFineTotal() function (without parameter) of the base class.
// This is the CalculateFineTotal(double) function (with parameter) of the
audiocassette class.
// This function overrides the base class function, and any call to CalculateFineTotal()
from any instantiated AudioCassette Class will use this function, not the base class
function.
// This type of polymorphism is called overloading and overriding.
Public Overloads Overrides Function CalculateFineTotal() As Double
Dim daysOverdue As Int = CalculateDaysOverdue()
If daysOverdue > 0 Then
Return daysOverdue * 0.25
Else
Return 0.0
End If
End Function
32. 32
Polymorphism (Contd…)
// This is the CalculateFineTotal() function of the audiocassette class.
// This type of polymorphism is called overloading.
Public Overloads Function CalculateFineTotal(ByVal finePerDay As Double) As Double
Dim daysOverdue As Int = CalculateDaysOverdue()
If daysOverdue > 0 AndAlso finePerDay > 0.0 Then
Return daysOverdue * finePerDay
Else
Return 0.0
End If
End Function
End Class
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
33. 33
Polymorphism (Contd…)
Now lets look at some code that creates all these library items and
checks them in and calculates our fines based on returning them 3 days
late:
Public Class Demo
Public Sub Go()
// Set the due date to be three days ago
Dim dueDate As DateTime = DateAdd(DateInterval.Day, -3, Now())
ReturnMagazine(dueDate)
ReturnBook(dueDate)
ReturnAudioCassette(dueDate)
End Sub
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
34. 34
Polymorphism (Contd…)
Public Sub ReturnMagazine(ByVal dueDate As DateTime)
Dim myMagazine As Magazine = New Magazine
myMagazine.DueDate = dueDate
Dim amountDue As Double = myMagazine.CalculateFineTotal()
Console.WriteLine("Magazine: {0}", amountDue.ToString())
End Sub
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
35. 35
Polymorphism (Contd…)
Public Sub ReturnBook(ByVal dueDate As DateTime)
Dim myBook As Book = New Book
myBook.DueDate = dueDate
Dim amountDue As Double = myBook.CalculateFineTotal()
Console.WriteLine("Book: {0}", amountDue.ToString())
End Sub
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
36. 36
Polymorphism (Contd…)
Public Sub ReturnAudioCassette(ByVal dueDate As DateTime)
Dim myAudioCassette As AudioCassette = New AudioCassette
myAudioCassette.DueDate = dueDate
Dim amountDue As Double
amountDue = myAudioCassette.CalculateFineTotal()
Console.WriteLine("AudioCassette1: {0}", amountDue.ToString())
amountDue = myAudioCassette.CalculateFineTotal(3.0)
Console.WriteLine("AudioCassette2: {0}", amountDue.ToString())
End Sub
End Class
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
37. 37
Polymorphism (Contd…)
The output will look like the following:
Magazine: 3.75
Book: 2.25
AudioCassette1: 0.75
AudioCassette2: 9
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
38. 38
Why OOP
Facilitates team development.
Easier to reuse software components and
write reusable software.
Easier GUI (Graphical User Interface) and
multimedia programming.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
39. 39
Relationships in OOP
Advantages of 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.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
40. Inheritance:
Inheritance is “IS-A” type of relationship.
“IS-A” relationship is a totally based on Inheritance, which can be
of two types Class Inheritance or Interface Inheritance.
Inheritance is a parent-child relationship where we create a new
class by using existing class code. It is just like saying that “A is
type of B”.
For example is “Apple is a fruit”, “Ferrari is a car”.
“HOD is a staff member of college” and “All teachers are staff
member of college”. For this assumption we can create a
“StaffMember” parent class and inherit this parent class in “HOD”
and “Teacher” class.
40 Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
41. Composition:
Composition is a "part-of" relationship.
composition means use of instance variables that are references
to other objects.
In composition relationship both entities are interdependent of
each other for example “engine is part of car”, “heart is part of
body”.
Let us take an example of car and engine. Engine is a part of each
car and both are dependent on each other.
41 Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
42. Association:
Association is a “has-a” type relationship.
Association establish the relationship b/w two classes using
through their objects.
Association relationship can be one to one, One to many, many to
one and many to many.
For example suppose we have two classes then these two
classes are said to be “has-a” relationship if both of these entities
share each other’s object for some work and at the same time
they can exists without each others dependency or both have their
own life time.
For example, Employee and Manager relationship in an
organization.
42 Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
43. Aggregation:
One class work as owner
In association there is not any classes (entity) work as owner but in
aggregation one entity work as owner.
In aggregation both entities meet for some work and then get
separated.
Aggregation is a one way association.
Let us take an example of “Student” and “address”. Each student
must have an address so relationship b/w Student class and
Address class will be “Has-A” type relationship but vice versa is not
true(it is not necessary that each address contain by any student).
So, Student work as owner entity.
This will be a aggregation relationship.
43 Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
44. 44
Conclusions
An OOP program models a world of active objects.
An object may have its own “memory,” which may contain
other objects.
An object has a set of methods that can process
messages of certain types.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com
45. 45
Conclusions (Contd…)
A method can change the object’s state, send messages
to other objects, and create new objects.
An object belongs to a particular class, and the
functionality of each object is determined by its class.
A programmer creates an OOP application by defining
classes.
Company Confidential: Data-Core Systems, Inc. | datacoresystems.com