Polymorphism Overview - Reducing code size and a better user experience episode artwork

EPISODE · Feb 24, 2021 · 14 MIN

Polymorphism Overview - Reducing code size and a better user experience

from Develpreneur: Become a Better Developer and Entrepreneur · host Rob Broadhead

We start the next series of episodes with a polymorphism overview.  This is a core concept for proper object-oriented design.  Likewise, we will dig into several practical ways to use this. Polymorphism Overview - A Definition As with many topics, it seems best to start with a definition from Wikipedia. In programming languages and type theory, polymorphism is the provision of a single interface to entities of different types or the use of a single symbol to represent multiple different types. For our purposes, that symbol that is referred to can be considered a name.  The name can be a method, class, or property name. Class Vs. Object It is worth clarifying the difference between a class and an object.  We will be talking about these two terms a lot from here on out.  Therefore, let's remove any confusion.  A Class is the definition of a class.  Think of it as a set of rules or a template.  A simple pseudo-code example is below. Class MyExample { String name; String value; public whoAmI() { return this.name; } } An object or instance is an occurrence of a class.  In the example below, myPointer is an object (or instance) of the class MyExample.  These are simple examples.  However, the concept is simple.  In the real world, an example would be that there is a class called Mother, and your mom is an instance of that class. myPointer = new MyExample(); The General Concept And Examples Since this is a polymorphism overview, we now need to talk about examples.  In general, polymorphism allows us to provide commands to objects they can follow for their specific case.  We have examples of this throughout the real world via commands we give and questions we ask.  We can look at the request "tell me about yourself" as an example.  The response may be a name, a profession, a season of life, an entire life story, or countless other responses.  In this case, the object the person you are talking to will take that request and polymorphically respond.  It is polymorphic because the same command is understandable by each of us.  However, we will have different responses due to our personality (or class). In the code world, a command like this may be "save" or "print" or myriad other commands.  These allow us to "tell" a group of objects the same command and have each respond in a pertinent way. 

NOW PLAYING

Polymorphism Overview - Reducing code size and a better user experience

0:00 14:39

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

Frequently Asked Questions

How long is this episode of Develpreneur: Become a Better Developer and Entrepreneur?

This episode is 14 minutes long.

When was this Develpreneur: Become a Better Developer and Entrepreneur episode published?

This episode was published on February 24, 2021.

What is this episode about?

We start the next series of episodes with a polymorphism overview.  This is a core concept for proper object-oriented design.  Likewise, we will dig into several practical ways to use this. Polymorphism Overview - A Definition As with many topics,...

Can I download this Develpreneur: Become a Better Developer and Entrepreneur episode?

Yes, you can download this episode by clicking the download button on the episode player, or subscribe to the podcast in your preferred podcast app for automatic downloads.
URL copied to clipboard!