Polymorphism
Polymorphism
Polymorphism
event plan
Emerald View Elementary School
Abanoub Ezzat
Introduction to Object-
Oriented Programming
(OOP)
Object-Oriented Programming (OOP)
is a programming paradigm
that organizes code around
the concept of objects
Objects are instances of classes
that encapsulate data and behavior
OOP allows for code to be organized
into reusable, modular units,
making it easier to maintain and extend
Abanoub Ezzat 2
OOP is based on four fundamental
principles
Abanoub Ezzat 4
Inheritance
Inheritance is the process by which a class inherits
the properties and methods of another class
Inheritance allows for a parent class to be used as
a blueprint for creating child classes
Polymorphism can be achieved through
inheritance by using a parent class
as a parameter type in a method,
and passing in child classes as arguments
Abanoub Ezzat 5
Example of Polymorphism
through Inheritance in Dart
Suppose we have two classes,
Shape and Circle.
Circle is a child class of Shape and
inherits properties and methods from it.
We also have a drawShape() function
that takes an object of the Shape class
as an argument and calls its draw() method.
Abanoub Ezzat 6
Example of Polymorphism
through Inheritance in Dart
Now we can create objects of both
the Shape and Circle classes
and pass them to
the drawShape() function:
Abanoub Ezzat 7
Example of Polymorphism
through Inheritance in Dart
8
Abanoub Ezzat
Example of Polymorphism
through Interfaces in Dart
Interfaces are a contract that defines
the properties and methods that a class
must implement
Dart interfaces allow for Polymorphism
by allowing objects of different classes
to be treated as if they implement the
same interface
This means that objects can be treated
as if they have the same properties
and methods, even if they are of different types
Abanoub Ezzat Fundraising event plan 9
Example of Polymorphism
through Generics in Dart
Generics allow for the creation
of reusable code that can work with
a variety of different types
Dart's Generics allow for Polymorphism
by allowing objects of different type
s to be used interchangeably
in generic code
This means that a single method or class
can work with a variety of different types,
without having to be rewritten for each type
Abanoub Ezzat Fundraising event plan 10
Conclusion and Speaker
Introduction
In conclusion, polymorphism is a powerful
feature of object-oriented programming
that allows for greater code flexibility My name is Abanoub Ezzat
Abanoub Ezzat 11