2,759 reputation
1228
bio website
location Argentina
age 37
visits member for 3 years, 7 months
seen 9 hours ago

Software developer and science fiction fan.


Aug
6
awarded  Nice Answer
Aug
5
comment Limitations of Polymorphism in statically typed languages
If you need to do completely different things (that is, differently "named" actions) for different types, then your method/function is not polymorphic. This isn't a flaw of static typing or polymorphism, but a problem with your design. Also, your example isn't very good: you can very well doSomething with polymorphism, for different Node types!
Aug
2
comment Why do game developers prefer Windows?
@TM I pay for games on Linux. Ever heard of the Humble Bundle? I never pay less than $10. If Steam and games ever get ported to Ubuntu (a possibility Valve is starting to explore), I will pay for AAA games as well. Yes, AAA prices for AAA games on Linux. Us Linux fanboys aren't cheapskates.
Jul
31
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
Sorry, Joachim Sauer already mentioned "provable" properties, which you disliked. In general, you've merely restated existing answers. Honestly, I don't know what you're looking for...
Jul
31
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey Yes, your answer is a restatement of what has been said. In Java there is a getClass() method, so? It's NOT part of the object's behavior. It's a meta-property if you will. And you shouldn't be using it in extendable code anyway. Now, please provide a NON-TRIVIAL example.
Jul
31
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey No, what you call #class is the type's name. It is mentioned as part of a type's specification in the paper, but since it's neither a "behavior" or a "history" property, it's not relevant for LSP. Since your example is trivial, you can bet it's not an oversight of the paper ;) By this point you should be trying to find a non-trivial example which shows introspection is incompatible with LSP.
Jul
31
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey if you've already read Liskov's paper, then you know your suggested property property q(x) = x.class.name == 'T' is neither a behavioral nor a history property, and therefore outside the scope of LSP. In general it's also an anti-pattern to check for a type's name!
Jul
31
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey, you should remove the duck-typing tag, since it isn't relevant. Also, LSP is a property of the system (i.e. of all (T, S) pairs), not of any specific pair.
Jul
31
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey Just checked the paper. Most of the introduction is spent describing what Liskov considers "relevant properties", what she calls "safety properties". Read it and all your questions will be answered :)
Jul
31
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey I've already given the reference: Wikipedia quotes the succint form of LSP, from the paper. It is clear that it's not a property of (A, B), but of every (A, B), i.e. of the whole design of the system. Sorry to be rude, but by now I think you have a problem understanding mathematical formulations. It's obvious Barbara Liskov didn't consider the "name of the type" a relevant property, otherwise her LSP would never hold. If we haven't convinced you yet, there's nothing more to do. I suggest you read the paper.
Jul
30
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey You've been presented with clear definitions. An object's class isn't part of its behavior or contract or whatever you want to call it. You are equivocating "property" with "object field, such as x.myField", which as has been pointed out, it is NOT the same. In this context, a property is more like a mathematical property, like type invariants. Furthermore, it's an anti-pattern to check for the exact type if you want duck typing. So, what is your problem with LSP and duck typing, again? ;)
Jul
30
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey In answer to your question: no, LSP is not a property of a pair (A, B), but of your overall design. LSP pretty much depends on the code, which must be designed such that substitutions by subtypes don't break it.
Jul
30
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey LSP holds (or doesn't) for a specific design. It is something to look for in a design; it's not a property of a language in general. It doesn't get any more precise than the actual definition: Let q(x) be a property provable about objects x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T. It's obvious that x.class is not one of the interesting properties here; otherwise Java's polymorphism wouldn't work either. There is nothing inherent to duck typing in your "x.class problem". Do you agree so far?
Jul
30
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey Also note that your example of x.class == A violates both LSP and duck typing. No sense in using duck typing if you're going to check for the actual types.
Jul
30
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey The precise definition of LSP is stated in Wikipedia in terms of subtypes. The informal definition is Liskov's notion of a behavioral subtype defines a notion of substitutability for mutable objects; that is, if S is a subtype of T, then objects of type T in a program may be replaced with objects of type S without altering any of the desirable properties of that program (e.g., correctness).. The exact class of an object is NOT one of "the desirable properties of the program"; otherwise it would run contrary to not only duck typing but of subtyping in general, Java's flavor included.
Jul
30
revised Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
added 116 characters in body
Jul
30
answered Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
Jul
30
comment Is Liskov Substitution Principle incompatible with Introspection or Duck Typing?
@Alexey: if you write something that depends on x.class == A, then it is your code that violates LSP, not the language. It is possible to write code that violates LSP in almost every programming language.
Jul
23
comment What are the factors that have made Java a success as a programming language in enterprise computing?
@ThorbjørnRavnAndersen Wow, are you seriously going to argue JWZ didn't like Java, when he said that it's "the best language going today" (read the article you quoted!)? I give up.
Jul
23
comment What are the factors that have made Java a success as a programming language in enterprise computing?
@ThorbjørnRavnAndersen Yes, I'm talking from experience. I'm a professional Java programmer working on existing codebases, as I guess many of us are. I'm talking from experience: Java's verbosity and tendency towards boilerplate sucks :)