Skip to main content

Timeline for Generics vs common interface?

Current License: CC BY-SA 3.0

6 events
when toggle format what by license comment
Dec 13, 2015 at 19:22 comment added jungle_mole @DeadMG and that's my point: intellisense can't do it: use generic, so it could? does it matter? when you get the object by its interface, why downcast it? if you do it, it's bad design, no? and why and what is "resolve overloads"? user must not decide, whether call method or not based on derived type if he delegates the call of right method to system ( which polymorphism is). and this again leads me to a question: are generics useful outside of containers? i'm not arguing with you, i really need to understand that.
Nov 23, 2015 at 13:36 comment added DeadMG @zloidooraque: It has nothing to do with the environment. Intellisense cannot tell you if an IBusinessObject is a BusinessObject1 or a BusinessObject2. It can't resolve overloads based on the derived type that it doesn't know. It can't reject code that passes in the wrong type. There's a million bits of the stronger typing that Intellisense can do absolutely nothing about. Better tooling support is a nice benefit but really nothing to do with the core reasons.
Nov 23, 2015 at 12:08 comment added jungle_mole @gexicide that's the point: I don't see where I need to use casts if I use common interface. I've never said "use Object". Also I understand why use generics when writing collections (DRY principle). Probably, my initial question should have been something about using generics outside the collections context..
Nov 22, 2015 at 22:41 comment added gexicide @zloidooraque: Also IntelliSense does not know which kind of Objects are stored in a repository. But yes, you could do anything without generics if you are willing to use casts instead.
Nov 22, 2015 at 21:47 comment added jungle_mole Thanks, that makes sense. But is the whole point of using this highly-praised language feature as simple as helping users who have IntelliSense switched off? (I'm exaggerating a bit, but I'm sure you get the point)
Nov 22, 2015 at 20:56 history answered DeadMG CC BY-SA 3.0