Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Polymorphism is about using objects of a type uniformly, regardless of their subtype.
22
votes
Separating business logic from data tempts me to use instanceof
One can separate data from behaviour and still use object oriented means and polymorphism. …
6
votes
Unused function parameters and polymorphism
Does this violate contemporary design principles?
No.
Is there really a problem with interface members having parameters that are used by some implementations, but ignored by others?
Not by …
3
votes
How would dispatch work in the Wizards and Warriors "rulebook"?
Your confusion comes from the fact Eric did not say much about the actual execution model (or evaluation model) for his proposed system. He leaves this to some degree "as an exercise to the reader". I …
20
votes
Accepted
Is ad-hoc polymorphism a good practice in functional programming?
It seems to be a common cargo cult today to ask if something is "a good practice". Usually, this is the wrong question, since in programming there is almost nothing "good" or "bad" per se - it always …
6
votes
Accepted
Should I still "replace conditional with polymorphism" if the condition is from dynamic load...
, then it is usually a good idea to implement this using neither conditionals nor polymorphism. … Moreover, you wrote that your original example is "bad", implying that "replacing conditional by polymorphism" would be "good". …
1
vote
How to use OO Design to Refactor a Library with Functions that are specific Product-aware
Somewhere in your code you have to store the specifics of each product. In your example, the natural place for this seems to be the Specs class, since I guess it is something like the "configuration" …
4
votes
How to retain the concrete type when writing base-class-oriented code?
JohnWu's approach of using templates is fine. Alternatively, instead of avoiding casts at any price, one could encapsulate them at a single place inside the BookSorter class, implemented in terms of a …
4
votes
Different scoring algorithms for different competition elements
However, that only makes sense if I create a different class for each different element, which doesn't seem right
To me, this feels perfectly right, since, it is just an application of the classi …
2
votes
Refactoring - Utility classes behavior under a common interface
it can have a private constructor and expose only static methods
Yes, it can, but there is no technical need for. So (besides some other good suggestions here) you should also consider the most s …
1
vote
Inheritance in imperative programming
I think the easiest way to understand this is by looking at a simple example in C: the qsort function of the standard C library. As a user of that lib, you can provide an arbitrary comparison function …
5
votes
Accepted
GUI applicaton states and polymorphism
One can use MVP (Model View Presenter) here. This decouples the view from the view's logic and is typically used to make views exchangable, but there is no reason why it cannot also be used to exchang …
1
vote
Accepted
How to change this implementation to cover drawbacks of Mediator Design Pattern here
I think I understand what you are after, but first note class FontDialogDirector is essentially a container for a specific list of Widgets, it is actually the coded definition of which Widgets your di …
7
votes
Are objects that can pass more than one IS-A test really polymorphic?
You are confused because you think of inheritance and polymorphism as separate concepts. … Another example is "static polymorphism" in C++ template meta programming, or polymorphic functions in Python, like shown here. …