Re: Static vs Dynamic

From: Darren (pyedarren_at_hotmail.com)
Date: 10/28/04


Date: 28 Oct 2004 08:15:04 -0700

Matthew Danish <mrd+nospam@cmu.edu> wrote in message news:<87wtxdt7uh.fsf@mapcar.org>...
> pyedarren@hotmail.com (Darren) writes:
> > If you are a bad Java OO designer, yes. You gain nothing particularly
> > useful from either. If you have a good design, you have scoping and
> > checking when you should and you dont rely on casts to fix your lack
> > of design. Casting in the examples we have been evaluating is only
> > necessary because the designs are bad.
>
> No; casting is necessary in order to have polymorphism in Java. If
> you have been paying attention to my other responses, you would
> realize that Java's way of doing polymorphism is inferior and badly
> designed. It is Java's fault.

It is necessary to a degree yes, but if you have to cast excessively
you have an inefficient and poor design and that's not Java's fault.

>
> > You can very easily using reflection without casts. See my solution
> > to Pascal's Visitor Pattern problem. When using reflection properly
> > you don't even need casts...and its the static types that allow you to
> > do it.
>
> This is funny. Do you know where the ideas behind Java's "reflection"
> API come from? Take a wild guess.

Yes I know where it came from. Many languages have capabilities that
were inspired by Lisp. Lisp has many powerful ideas. I use Linux
from time to time, maybe Linux is funny because it was inspired by
unix? Maybe Lisp is funny because it was inspired by machine code?
What's your point?

>
> (And using reflection in such a manner is still quite ridiculous,
> remember what reflection is for: inquiring about the system, and
> perform operations upon the system itself; not for manipulating
> objects within the system!)

That's *one* use of reflection. It is intended for MUCH more then
that. Using reflection like I have is done all the time. Probably
not by Joe IT programmer, but by people that know the language. Ever
hear of J2EE, Javabeans, IDE's, debuggers, Beanshell...(insert
hundreds of other applications here) take a guess how they work.

>From your "funny" response, I am sure you have no idea about Java or
how to properly use it. Which might explain why you end up with so
many casts and see it as a huge problem.



Relevant Pages

  • Re: Programaticly call a method from a different object?
    ... In most cases, reflection is not necessary. ... A better design removes the ... I do not answer questions on behalf of my employer. ... programmer helping programmers. ...
    (microsoft.public.dotnet.general)
  • Re: Dynamic Method Invocation (specific line)
    ... I am using Java Reflection API to dynamically invoke methods from ... why are you trying to break the fundamental object-oriented nature of Java in the first place? ... The Java approach would be NOT to use reflection but to design your code. ...
    (comp.lang.java.programmer)
  • Re: Optical Sensor (different from the 2-d sensor)
    ... Wescott Design Serviceshttp://www.wescottdesign.com ... "Applied Control Theory for Embedded Systems" gives you just what it says. ... I would try first with an LED or laser + a PIN photodiode. ... You may have more of a challenge minimizing the coupling between the transmitter and receiver with no reflection than you do with anything else. ...
    (sci.electronics.design)
  • Re: Static vs Dynamic
    ... > are peppered with casts, and search for ones that will draw less ... > How do you know that the design with minimal casts is the best one? ... That is where in a statically typed OO language you would have the ... Java internally implements many design patterns ...
    (comp.lang.lisp)
  • Re: Static vs Dynamic
    ... > of design. ... casting is necessary in order to have polymorphism in Java. ... Do you know where the ideas behind Java's "reflection" ...
    (comp.lang.lisp)