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
25 views

Recording item creation events on a blog engine [closed]

On a website there are various content types: blog post, user and comments. Each time one of those is created, I record a corresponding "event" in an "event" SQL database table, so I can display a ...
5
votes
2answers
217 views

Free general e-book downloader

So I decided to expand a little one-off C# console program I wrote awhile ago to download the free e-book offered by Syncfusion, and decided to also do it for other free e-book publishers... like O'...
5
votes
1answer
93 views

Building a model-view-controller application in PHP

I've seen at least two recent PHP questions that would do well from a Model-View-Controller ('MVC' from here-on-out in this question) setup. Now, me, being the horrible person I am, I wanted to build ...
4
votes
0answers
58 views

There Was an Old Lady - generate lyrics to a cumulation song

This is a problem from exercism.io. View repo here (contains full example of song). Problem statement: Generate the lyrics of the song 'I Know an Old Lady Who Swallowed a Fly' While you could ...
7
votes
0answers
118 views

Multiple similar manager classes for handling scroll lists

I am working on my first object-oriented programming project, written in C# for Unity. My code does what I want it to do, but I am wondering if there is a better way to do it. I think I am building ...
5
votes
2answers
251 views

99 Bottles of Beer using polymorphism

This was part of an exercise from exercism.io. If you fancy, view the repo here. Given problem statement: Write a program which produces the lyrics to that beloved classic, that field-trip ...
2
votes
2answers
69 views

Represent a person who has different roles for different offices

People have different types of roles depending on the office they are working at. For example, a person has two roles (cashier,cleaner) at OfficeMax and five roles(manager,security,etc) at OfficeLess. ...
3
votes
3answers
228 views

Models an assembly line

The gist of the code is that there's an assembly line of products, in this case Toy and Book, that get inspected by workers who then add them to a box. The box is then sent to someone who knows what ...
2
votes
2answers
126 views

Calculate area and perimeter for shapes: polygon, circle, rectangle and triangle - follow up

This is the new code after the changes suggested by @Cody Gray in the last question: Calculate area and perimeter for shapes: polygon, circle, rectangle and triangle This is my project on ...
6
votes
1answer
642 views

Calculate area and perimeter for shapes: polygon, circle, rectangle and triangle

This is my project on inheritance and polymorphism , I got the main file from my teacher and built the project base on it .My base class is Shape .Polygon and Circle Inheritance from shape . Triangle ...
7
votes
2answers
63 views

C function to print arrays of arbitrary data type

C is naturally clumsy at polymorphism but I wanted to avoid duplication so I wrote this function. But I'm sure there are ways left to improve it. Please not that for brevity's sake not all data types ...
0
votes
0answers
82 views

Using polymorphic objects to represent parts of a deconstructed sentence

I am trying to make a chatbot using javascript by deconstructing a sentence into its intent by separating the Noun's Verb's, Adjectives, Durations's, Numbers etc... to construct a data query to try to ...
-1
votes
1answer
421 views

Calculate the area of different shapes using polymorphism (virtual and override methods)

I have written code to calculate the area of different shapes using polymorphism (virtual and override methods) and it is working as expected. Can anyone please review this and let me know how I can ...
0
votes
1answer
118 views

polymorphism with object ArrayList

I've an ArrayList of Object that could contain String, ...
-1
votes
2answers
117 views

Very complicated Java HelloWorld app

This program attempts to shows the basic concepts of inheritance and polymorphism. In what ways could the code be modified to better demonstrate those concepts? The interface, abstract class and the ...
1
vote
1answer
53 views

Simulating dynamic polymorphism in C

This code snippet is a research attempt to find means for dealing with dynamic polymorphism (in C): two or more related "classes" share a common interface. Here is my best shot: ...
7
votes
0answers
172 views

A vector-like polymorphic container to store objects from a type hierarchy in contiguous memory

Normally, in order to have a polymorphic collection, we store pointers to a base class: ...
7
votes
1answer
151 views

Array view adaptor class for static polymorphism over network header parsing

Some context: I have some existing code to populate network header structs from istreams. A motivating excerpt: ...
7
votes
1answer
55 views

Kattis “Hitting the Targets” utilizing a polymorphic relashionship

In order to learn C++ I have written a solution to this Kattis "Hitting the Targets" problem Basically the program is to accept some shapes (circles and rectangles) on std in and a set of points and ...
6
votes
2answers
188 views

Return the correct object type in Javascript

I am currently wondering if the following piece of Javascript code could be simplified? I would like to return the correct {},[],"" without having to pass a type as ...
3
votes
2answers
83 views

Triple-type template container

I made a triple-type container, that is, a single type that can store a value, under one of the three types used. It's somewhat similar to Boost::Variant. The header file (multitype.hpp): ...
4
votes
1answer
58 views

Polymorphic pointers-to-functions whose parameters are void pointers as arguments in C

My question is about this sort of table that's simplified here. Often, I find myself putting this element, (int (*)(const void *, const void *))&strcmp for <...
4
votes
2answers
73 views

Data structure to store large numbers of runtime-dependent arithmetic types

Warning: lots of code. If it's too much, please focus primarly on channel.h and channel.hpp. This is my first time posting on ...
5
votes
1answer
163 views

Initializing characters in a visual novel game

I am making a visual novel game and I was wondering is there a better way of setting character attributes and initializing than the way that I have done down below. As you can see I did an abstract ...
8
votes
1answer
119 views

Accessing the Stack Exchange API

Part of a project I'm getting started on requires access to the Stack Exchange API for certain data, as a result I built a .NET implementation to interact with it. The implementation is pretty simple,...
0
votes
2answers
87 views
6
votes
2answers
218 views

Dependency problem in C#, through polymorphism, and appropriate design pattern

I'm currently working on a project which involves EntityFramework with a (very) rich model (lots of inheritance). I'm currently facing a problem, quite interesting in my opinion. My model is ...
4
votes
1answer
114 views

Calculating a postfix expression

I've got the following code in my calculator project: ...
1
vote
0answers
55 views

Find the appropriate transformer for an abstract value

I want to get rid of the following code duplication within the MyFacadeBean. Consider the following situation: ...
5
votes
1answer
83 views

Polymorphic TLV serialization

Inspired by this question I decided to write an alternative that uses polymorhphism and a Factory pattern. The code works for the subset of implemented types, namely ...
2
votes
3answers
244 views

Polymorphically processing 2 & 3 dimensional objects

It seems there are a lot of "empty containers" (I do not know the correct, technical term) with regards to multiple levels of abstract classes and functional interfaces with little or no code. Is ...
2
votes
1answer
252 views

Sorting polymorphic classes

I'm learning from "Jumping into C++" by Alex Allain (sample chapter and TOC) and solved the first problem in Chapter 26 "Inheritance and Polymorphism". I'm especially concerned about my use of ...
3
votes
1answer
594 views

Check if JavaScript input is empty

Having a general utility function to see if the input is empty makes sense to me. Empty means different things depends on the type. I just spent ~5 minutes writing this one up, so I'm sure it's ...
6
votes
2answers
732 views

Google reCAPTCHA Validator: Iteration II

This is a follow-up to the other post I made (less than an hour ago) about my Google reCAPTCHA C# implementation: Google reCAPTCHA Validator This adds support for error messages, so that you can ...
3
votes
1answer
400 views

Google reCAPTCHA Validator

This entire class came out of a chat discussion, and I'm curious on how it looks. (This is like literally 30 minutes of development time.) The idea is to allow very easy, quick implementations of ...
7
votes
3answers
222 views

Implementing Dynamic Network Message Handling (Part II)

This is an iterative review request of this other question I posted. As a follow up to that previous question, I changed the pattern completely and I went to an events-based approach, which might be ...
12
votes
2answers
329 views

Implementing Dynamic Network Message Handling

I'm trying to handle network messages in a dynamic, and effective way, though I feel I've overthought it again. As of now, I have a very structured approach, but it feels as if it's a lot of overhead ...
7
votes
1answer
395 views

Conversion calculator using polymorphism and Swing

This is my first attempt at a program (outside of school) and I was trying to implement and learn polymorphism on a conversion calculator for volumes and weights. I found myself using long ...
2
votes
1answer
65 views

Polymorphic components for graphics and program state

I asked this question on StackOverflow, got some answers, most notably a link to this one, and basing on that I've implemented this: ...
3
votes
0answers
529 views

Efficient compile-time directed graph

During my research in Rigid Body Dynamics, (where Contact Graphs are used to solve the contact problem) I came across the question if it is possible to define at compile time a directed graph (class) ...
2
votes
1answer
146 views

Vehicle running cost calculator

I'm making a road tax data calculator/parser for practice. I do this because I want to learn more about OOP and arrays with its functionality. On my previous post, I made this same application but ...
8
votes
1answer
153 views

Polymorphic animals speak their name and make a noise

I'm new to GNU Smalltalk. I'd like to port a script I've written in Ruby, Scala, CoffeeScript, and several others. It's the one I use to try to learn the classic OOP concepts of abstract classes, ...
3
votes
1answer
669 views

Text-based Tetris game with CRTP - follow-up

Previous question: Text-based Tetris game - follow-up - final Summary of improvements: Implementation of a Drawable class Separate functionality, input moves to <...
4
votes
2answers
793 views

Inserting and displaying books

I'm trying to write a program where you can insert and display some books (without using a database). For doing this, I use three classes: Book - is the base ...
8
votes
1answer
289 views

Transformation of abstract models

In one of my recent projects I faced the problem of transforming an abstract class into another abstract class. The classes were structured like this and are part of an api for questionnaires: ...
6
votes
1answer
391 views

Image Processing Pipeline

I'm currently toying around with some Computer Vision algorithms and always wanted to learn more about templates, so I came up with the idea to build a templated Image Processing Pipeline. I want the ...
8
votes
3answers
205 views

Single inheritance polymorphism

I am learning about polymorphism in C++ and decided to implement an example. Is there anything I need to fix in my code? This compiles and runs. ...
3
votes
1answer
64 views

Type dispatch based on runtime value

Suppose we're implementing an interpreter for the bytecode of some stack machine. Let every element of the stack be a Word8, and let the stack be represented by a ...
7
votes
2answers
415 views

Interface-based polymorphic collection

Here is a small C++11 utility collection to store any object that satisfies a given interface. Only the basic concepts are provided, I did not try to create a full collection: ...
5
votes
1answer
179 views

Changing the type of an object inside a method?

First off, this is not my code. I'm curious what everyone thinks about changing the type of an object inside of a method then modifying the properties of the cast type. I wanted to use composition to ...