2,772 reputation
1230
bio website
location Argentina
age 38
visits member for 3 years, 11 months
seen 5 hours ago

Software developer and science fiction fan.


May
16
comment Is it poor programming practice to pass parameters as Objects?
@Kaz If you want to write experimental code against the conventions and assumptions of a language, by all means do it... on your own. If working with a team, follow the conventions. It's as simple as that. Also you are turning this into a debate about creativity, which is absurd. If you use a hammer as a hammer, instead of as a screwdriver, you are not being any less creative; you are using a tool for its best job.
May
15
comment Is it poor programming practice to pass parameters as Objects?
But what you call "type A OOP" is not what happens when programming in Python or Ruby either. So not only you'd be subverting Java's type system, you wouldn't even be doing what's recommended in Python. Duck-typing means you don't explicitly cast. This is regardless of how it's implemented internally in Python, which has nothing to do with the programming paradigms it supports.
May
15
comment Is it poor programming practice to pass parameters as Objects?
I don't know how Python works internally (I suspect its dispatch system doesn't work like you describe it, but I may be wrong), but that's irrelevant. How a language is implemented internally is orthogonal to the paradigm it supports. An OOP language may very well be implemented internally using a paradigm incompatible with OOP. When writing Java code, however, you're supposed to use OOP; otherwise you've chosen the wrong tool for the job.
May
15
comment Is it poor programming practice to pass parameters as Objects?
I don't think you have to explicitly cast in Python or Ruby (that runs contrary to their philosophies, as far as I can tell). E.g. you are encouraged to use Duck Typing in Python; if you are casting, you are doing it wrong. And in Java, if you receive an Object but then cast it to a more appropriate subtype you are also doing it wrong! You are subverting Java's static type checks to gain nothing in return; you are essentially saying "I know how this will be used, but I don't want to let the compiler know. Just because."
May
15
comment Is it poor programming practice to pass parameters as Objects?
@Kaz Disagreed. Hardcoding the type casting in your method is not like letting a language (such as Python) handle it. Besides, if your method is going to crash and burn because the typecast was incorrect, how is it more "dynamic"? You are subverting Java's compile-time checks, and getting nothing in return.
May
15
comment Is it poor programming practice to pass parameters as Objects?
@Kaz Type casting in no way makes Java "more dynamic". It just hides the types hardcoding inside the method, instead of making types explicit in the method's signature, making the code more brittle and harder to understand. How is that more dynamic, or a good thing?
May
15
comment Is it poor programming practice to pass parameters as Objects?
The value of inheritance is not "appreciated" by type casting. That's throwing OOP and polymorphism completely out the window (regardless of type system!).
May
15
comment Is it poor programming practice to pass parameters as Objects?
Java and JavaScript are completely unrelated, so this answer is really bad.
May
15
comment Is it poor programming practice to pass parameters as Objects?
@Kaz That's absurd. If you program in Java, follow Java conventions. If you program in Python, follow Python's. And not all of us think the arguments for dynamic type systems are "solid".
May
15
comment Is it poor programming practice to pass parameters as Objects?
-1 Except in the OP it's made clear the programmer is not doing a form of duck typing, but in some cases actually casting to the "correct" type. This isn't at all a recommended practice in languages with dynamic typing such as Python, Ruby, etc. Instead, it's a deep misunderstanding of how OOP works, regardless of type system.
May
13
comment Why the recent shift to removing/omitting semicolons from Javascript?
@gnat The blacklisted question actually has some very interesting examples of why omitting the ; can break your code. So I'd say it's a useful reference for this question.
May
10
comment Scratch - why do schools teach students a language that is not used anywhere else?
@NimChimpsky You think something theoretically but disregard the first-hand experience of someone (Eric King) who is telling you the opposite! Even if you don't believe the claims in Scratch's homepage, at least you must believe someone who has witnessed its success, right?
May
10
comment Scratch - why do schools teach students a language that is not used anywhere else?
@NimChimpsky Sorry, you are ranting :) It is used by children under 8 (with parent supervision), as explained by its homepage. You are begging the question!
May
10
comment Scratch - why do schools teach students a language that is not used anywhere else?
Ok... this is heading into Rant Territory, and therefore off-topic in Programmers.SE :)
May
10
comment Scratch - why do schools teach students a language that is not used anywhere else?
@NimChimpsky Says who?
May
10
comment Scratch - why do schools teach students a language that is not used anywhere else?
What is a "normal" and "proper" language, anyway? Some have argued that teaching any of the following to beginners is dead wrong: C++, Java, OOP, imperative programming. (And not because they are difficult, but because they mislead beginners into thinking in a certain way -forever-).
May
10
revised What principle of OOAD is this pattern breaking?
spelling: principal -> principle
May
10
suggested approved edit on What principle of OOAD is this pattern breaking?
May
9
revised Why is there no 'finally' construct in C++?
edited tags
May
9
comment How is referential transparency enforced?
@JohnDoDo If you want to return an integer, then f cannot have type IO Integer (that's an action, not an integer). But then, it cannot call the "current date", which has type IO Integer.