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.
120 questions
1
vote
0
answers
95
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
946
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
733
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
95
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
135
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
283
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
93
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
125
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
142
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...
1
vote
1
answer
167
views
Entity Framework - component shop using polymorphism and generic repository
I am creating a .NET Framework MVC EF application for PC components. I wanted to make full use of inheritance, polymorphism and generic repository pattern - but was wondering if my initial design ...
4
votes
4
answers
3k
views
Model animals using inheritance in Java, revised
Yesterday I posted my first solution to an interview problem here. I am now aware that I have many weak spots in Java and need to do extensive review before tackling any more interviews. Having said ...
0
votes
1
answer
53
views
Inquiring possible alternatives to custom hierarchy-aware smart pointer
I have a medium sized project that uses a class hierarchy that essentially boils down to:
...
3
votes
2
answers
10k
views
C++: Event system for game engine
Since writing your own C++ game engine seems to be really popular these days (seriously just look at the amount of people presenting their WIPs on YouTube) I figured I'd try it myself.
My mental model ...
4
votes
1
answer
759
views
Efficient vector-like polymorphic container which retains type information
This is my attempt of implementing an efficient, cache-friendly, vector for polymorphic objects.
From now on I will refer to "virtual functions" as functions which are dependent on an object'...