Skip to main content
10 events
when toggle format what by license comment
Jul 21, 2012 at 8:34 comment added Andrey Agibalov this worths reading - pragprog.com/articles/tell-dont-ask
Jul 18, 2012 at 4:05 comment added Andrey Agibalov en.wikipedia.org/wiki/Liskov_substitution_principle
Jul 17, 2012 at 19:50 comment added Telastyn @loki2302 - But that's the thing: you can properly ignore the type of the object in that case. As soon as it's trivially subtyped (or tagged with an empty interface) you can't. The callsite needs to know about the subtypes and change behavior based on them.
Jul 17, 2012 at 19:12 comment added Andrey Agibalov In OOP there's no obvious boundary between data and behavior: objects communicate with messages, so whenever you say person.getName(), it can't be considered data access. You'll never know whether getName() is just return name or is it not that straightforward ORM call.
Jul 17, 2012 at 18:36 comment added Telastyn But that's the thing; polymorphism is behavior, not data. To get any sort of behavior change with an empty type you need some external code to be able to identify and switch on it. In languages without dynamic dispatch (or pattern matching in some cases) that is awkward at best.
Jul 17, 2012 at 18:17 comment added Andrey Agibalov Your answer is pretty generic - you have also covered polymorphism since it also can be considered "encoding information to the type system".
Jul 17, 2012 at 16:06 comment added Telastyn @loki2302 If you don't need to extract the information, there's no reason to subclass it. I'd love to see why people downvoted, since it's fairly clear from my perspective that it's an anti-pattern.
Jul 17, 2012 at 13:50 comment added Andrey Agibalov You don't normally need to extract that information. If you really need to, it feels like there are some problems with your design. Code like if(a instanceof X) method() can always be refactored to a.method() without need to get exact type of a.
Jul 17, 2012 at 12:27 history edited Telastyn CC BY-SA 3.0
clarification.
Jul 17, 2012 at 11:07 history answered Telastyn CC BY-SA 3.0