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.
36
votes
How is polymorphism used in the real world?
Stream is great example of polymorphism.
Stream represents a "sequence of bytes that can be read or written". But this sequence can come from file, memory, or many kinds of network connections. … Some would say Stream is wrong example of polymorphism, because it defines many "features" that it's implementors don't support, like network stream only allowing reading or writing, but not both at the …
1
vote
Classic inheritance problem?
I'm personally perfectly fine using downcasting. Simply because it is same as language-aided visitor pattern. It becomes even better if you create HasRadius interface/abstract class, that allows you t …
7
votes
Combinatorial explosion of interfaces: How many is too many?
The point of interfaces is to allow piece of code to express what API it works with. And then allow this API to be implemented by multiple classes. In your case, instead of AforB or AforC, make it Bne …
0
votes
Clarification about Polymorphism / Inheritance
The virtual method called always depends on type of concrete instance in memory and never on how this instance is accessed or type of variable the instance is accessed from. The type of variable just …
6
votes
Limitations of Polymorphism in statically typed languages
Best fit would probably be Visitor pattern.
And if you need to do things like this, then you should re-think your object model, because having behavior, that works only on specific type should be par …