Artwork

Content provided by Rob Broadhead. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Rob Broadhead or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

Polymorphism Overview - Reducing code size and a better user experience

14:39
 
Share
 

Manage episode 285772723 series 1919132
Content provided by Rob Broadhead. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Rob Broadhead or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

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.

  continue reading

754 episodes

Artwork
iconShare
 
Manage episode 285772723 series 1919132
Content provided by Rob Broadhead. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Rob Broadhead or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

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.

  continue reading

754 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Quick Reference Guide