In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface.

learn more… | top users | synonyms

0
votes
0answers
12 views

How to use the strategy pattern with STL containers? [migrated]

Assume that I have a strategy interface named BinaryClassifier that can take a Sample and return a ...
6
votes
1answer
122 views

Variadic templates and pointers to member functions to achieve a named-parameters interface in C++

I studied a bit and packed all the suggestions that I received here: Fluent interface and polymorphism and I came up with this: ...
7
votes
6answers
507 views

Fluent interface and polymorphism

EDIT: For further improvements see the related question: Variadic templates and pointers to member functions to achieve a named-parameters interface in C++ I would like to improve the interfaces of ...
5
votes
2answers
71 views

Avoiding casts in abstract types

I asked this question on Stack Overflow and in the comments someone had this to say. In a proper design, you should almost never have to do a dynamic_cast, even if it's hidden inside some nice ...
7
votes
1answer
99 views

Concept based polymorphism

I have a concept based polymorphism example listed below. I allow the user to provide any type that implements the draw method and then I add it into a vector of ...
0
votes
1answer
135 views

Understanding polymorphism in Python

I feel like I don't understand how polymorphism works in Python. Here is something I put together. ...
2
votes
2answers
100 views

designing application using polymorphism

I have created a polymorphic system, but I don't know whether this is the correct way of doing it. Am I abusing Polymorphism here? Here is the code: ...
3
votes
2answers
141 views

Null Object pattern with simple class hierarchy

I have a simple two-class hierarchy to represent U.S. ZIP (12345) and ZIP+4 (12345-1234) codes. To allow clients to allow both types for a field/parameter or restrict it to one type or the other, the ...
3
votes
1answer
126 views

Hardware resource Open/Close methods

So I'm making a program that is a serial port wedge. In other words I want it to listen to a serial port. If data comes in, wait a given amount of time, then play a sound and finally send the data ...
2
votes
4answers
206 views

Understanding Interface

...
0
votes
1answer
151 views

Is this the proper way to find the subclass of a polymorphic superclass?

I came across polymorphism in the book that I'm reading and decided to do a little experiment. Essentially what I did was to create a base class called Asset and ...
10
votes
11answers
826 views

Design dilemma: extensibility vs simplicity

Here is my problem abstracted to Bird classes. I know that number of Birds will increase on the future and new behaviors might ...