Questions tagged [polymorphism]
In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface.
125 questions
4 votes
0 answers
105 views
Integration Test for Polymorphic data models that save data to MySQL
As noted by @TobySpeight in his answer to Polymorphic data models that save data to MySQL and restore data from MySQL the test code should also be reviewed. His ...
4 votes
2 answers
142 views
Polymorphic data models that save data to MySQL and restore data from MySQL
This is a follow up question to Inserting and retrieving data MySql Database access in C++ using Boost::ASIO and Boost::MySQL. I have reduced the amount of code to be reviewed by presenting only one ...
7 votes
1 answer
643 views
A static version of std::polymorphic
There sometimes is a desire to have access to the base class of a polymorphic object without wanting the overhead of dynamic allocation, see for example this question. For a more value-like way of ...
7 votes
3 answers
384 views
Adapting a hierarchy of polymorphic classes to std::variant
The idea of the following is to adapt a hierarchy of polymorphic classes DerivedX to std::variant without modification to ...
4 votes
1 answer
126 views
Maze game from book Design Patterns with smart pointers and polymorphism
The Design Patterns book chapter 3 about Creational Patterns starts with a maze game. They use the maze as an example throughout the chapter and instead of rooms they have also things like enchanted ...
1 vote
0 answers
162 views
Runtime function overloading / dynamic dispatch for Python (2nd revision)
Second revision of the original post: Function overloading / dynamic dispatch for Python TL;DR: Improved version of this library[^1] based on previous reviews and criticism. It provides runtime ...
8 votes
2 answers
998 views
A tree of polymorphic types (Crafting Interpreters Book)
I am following the book crafting interpreters by Robert Nystrom using C++. In the book we use an Expr base class to describe expressions in the language lox. ...
5 votes
2 answers
1k views
Function overloading / dynamic dispatch for Python
UPDATE: Second revision on separate post. Runtime function overloading / dynamic dispatch for Python (2nd revision) When I first started using Python I had a rough time dealing with some of it's ...
6 votes
2 answers
793 views
polymorphic message container [closed]
Any comments/suggestions on this design? I just want to hold onto an ordered collection of messages. Each message can be one of several types. I'm using some code analogous to this currently in a ...
-2 votes
1 answer
116 views
C++ compile time polymorphism example [closed]
I found an example using std::variant to provide compile time polymorphism as a possible optimisation to runtime polymorphism in 'Software Architecture Using C++', https://github.com/PacktPublishing/...
2 votes
2 answers
177 views
Cache for mesh objects
I'm creating a cache system for an object (Mesh) that is expensive to create. A Mesh can be created using a small amount of ...
2 votes
1 answer
307 views
Parametric visibility and order of tkinter labels
I'm writing software which allows a user to view data in a number of different formats, and they can switch between formats at any time. I'm wondering if there's a better way to do this than switching ...
4 votes
1 answer
116 views
Logistics project that implements several shipping APIs
I have a Python logistic project that implements several shipping APIs using class inheritance. Each of those classes must do three things: Fire requests to each endpoint with the proper parameters ...
1 vote
1 answer
156 views
One-time dynamic, many-time *almost* static type dispatch
Annoyed at the tension between good software design principles that require well-defined delimitations between interface and implementations, and the requirements for critical code to run fast, which ...
2 votes
1 answer
179 views
Gallery template class
I have created a template class Gallery which is intended to be used as a container for objects. I used a private member of type...