dinamic variables - help!!!!

Discussion in 'Java' started by whois, Jun 18, 2004.

  1. whois

    whois Guest

    Hi!
    I want to know if there is possible to read dinamicly variable or
    functions in java? (in perl it's possible!)

    I give an example:

    i have one String variable e.g. x="small test";
    create a second String named y="x";
    now, when i print the variable 'y', i want that the result doesn't be
    "x", but validate the result as another variable, and return "small
    test".

    this is a simple example, because i can use that concept to execute
    functions...

    thanks in advance.
    whois, Jun 18, 2004
    #1
    1. Advertising

  2. In article <>,
    (whois) wrote:

    > this is a simple example, because i can use that concept to execute
    > functions...


    The simplest way to do what you showed with strings in the example is
    probably a HashMap, but if you really want dynamic functions, there's a
    different way.

    Reflection lets you look at a class and discover what it contains. Look
    at methods such as Class.getMethod and Method.invoke.

    --
    Phillip Mills
    Multi-platform software development
    (416) 224-0714
    Phillip Mills, Jun 18, 2004
    #2
    1. Advertising

  3. Phillip Mills wrote:
    >>this is a simple example, because i can use that concept to execute
    >>functions...

    >
    >
    > The simplest way to do what you showed with strings in the example is
    > probably a HashMap, but if you really want dynamic functions, there's a
    > different way.
    >
    > Reflection lets you look at a class and discover what it contains. Look
    > at methods such as Class.getMethod and Method.invoke.


    It should be mentioned that you almost certainly shouldn't *want* to be
    doing this in the first place - a better design can usually avoid such
    things.
    Michael Borgwardt, Jun 19, 2004
    #3
  4. In article <>,
    Michael Borgwardt <> wrote:

    > Phillip Mills wrote:
    > >
    > > Reflection lets you look at a class and discover what it contains. Look
    > > at methods such as Class.getMethod and Method.invoke.

    >
    > It should be mentioned that you almost certainly shouldn't *want* to be
    > doing this in the first place - a better design can usually avoid such
    > things.


    It has always bugged the hell out of me when people have responded to my
    questions by trying to redefine my problem, so I try not to do it to
    others. :)

    --
    Phillip Mills
    Multi-platform software development
    (416) 224-0714
    Phillip Mills, Jun 19, 2004
    #4
  5. Phillip Mills wrote:
    > It has always bugged the hell out of me when people have responded to my
    > questions by trying to redefine my problem,


    Because you didn't manage to describe it adequately?

    Because you were about to do something utterly stupid?

    If you need predictable (not reliable, predictable) answers, hire a
    consultant and don't try newsgroups.

    /Thomas
    Thomas Weidenfeller, Jun 21, 2004
    #5
  6. In article <cb6ddq$ov1$>,
    Thomas Weidenfeller <> wrote:

    > Phillip Mills wrote:
    > > It has always bugged the hell out of me when people have responded to my
    > > questions by trying to redefine my problem,

    >
    > Because you didn't manage to describe it adequately?


    When the question isn't understood, silence is always an acceptable
    response.

    > Because you were about to do something utterly stupid?


    Usually it's because there are people so full of themselves that they
    feel obliged to act as know-it-alls. If they don't have the answer,
    then it must be the fault of the question, right?

    Or they have a particular agenda: "Tool X" is wonderful so let's change
    the problem's parameters until "Tool X" becomes an appropriate solution.
    (And heaven help the original poster if their question suggests that
    "Tool X" isn't perfect!)

    Or they just get cheap thrills out of implying that others are inferior.

    It's true that sometimes people post questions based on strategies that
    are full of holes, but to start by *assuming* that's the case strikes me
    as rude and ignorant.

    --
    Phillip Mills
    Multi-platform software development
    (416) 224-0714
    Phillip Mills, Jun 21, 2004
    #6
  7. On Mon, 21 Jun 2004 08:57:00 -0400, Phillip Mills wrote:

    >> Because you didn't manage to describe it adequately?

    >
    > When the question isn't understood, silence is always an acceptable
    > response.


    So..
    "I do not understand your vaguely defined
    question on points 2,3 and 7. Clarify those
    and I will give you the best answer."
    ...is *not* an acceptable response?

    You sound like you are saying
    "Tell me what I want to hear or be silent."

    That seems to fit the 'hire a consultant'
    solution that Thomas was referring to..
    You will not get that crap here, fortunately.

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
    Andrew Thompson, Jun 21, 2004
    #7
  8. whois

    Roedy Green Guest

    On Mon, 21 Jun 2004 12:33:46 +0200, Thomas Weidenfeller
    <> wrote or quoted :

    >Because you didn't manage to describe it adequately?
    >
    >Because you were about to do something utterly stupid?
    >
    >If you need predictable (not reliable, predictable) answers, hire a
    >consultant and don't try newsgroups.


    It is a matter of gift horses. People offer what they can. Often a
    problem falls apart easily if you simply redefine the problem, backing
    up a bit to think about the final desired result and not getting too
    hung up on HOW you get there.

    If you are too rude about the unwanted gift horses, you stop getting
    any gift horses.

    Think of the newsgroups as ongoing free brainstorming sessions. You
    don't want to throw cold water to discourage the flow of new ideas.


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 21, 2004
    #8
  9. whois

    Roedy Green Guest

    On Mon, 21 Jun 2004 08:57:00 -0400, Phillip Mills
    <> wrote or quoted :

    >It's true that sometimes people post questions based on strategies that
    >are full of holes, but to start by *assuming* that's the case strikes me
    >as rude and ignorant.


    Most of the people asking questions ARE newbies, or they are well
    known regulars. It means nothing about you that you are presumed a
    newbie when you are simply new to the group.

    On the other hand you exude entitlement which many find even more
    irritating than arrogance. Nobody OWES you any answer at all, much
    less one in the form you desire.

    If someone makes any stab at answering your question, they are trying
    to be as helpful as they can. The alternative would be to hold back
    the little info they can and leave you in the dark. If even there is a
    10% chance the answer could prove useful, I'd think you would feel
    grateful they tool the time to share that information. Most people
    ignored you entirely.

    If you want to control the way people answer you, you will have to pay
    them.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 21, 2004
    #9
  10. In article <9jc7wpdftkyt$.s56yt1232iiz$>,
    Andrew Thompson <> wrote:

    > On Mon, 21 Jun 2004 08:57:00 -0400, Phillip Mills wrote:
    >
    > > When the question isn't understood, silence is always an acceptable
    > > response.

    >
    > So..
    > "I do not understand your vaguely defined
    > question on points 2,3 and 7. Clarify those
    > and I will give you the best answer."
    > ..is *not* an acceptable response?


    Of course it would be acceptable. Where did I say that silence was the
    *only* acceptable answer?

    What I consider unacceptable is, "Only an idiot would put themselves in
    a position where that question was necessary, so -- without knowing a
    thing about your project -- here's what you should be asking instead."

    --
    Phillip Mills
    Multi-platform software development
    (416) 224-0714
    Phillip Mills, Jun 22, 2004
    #10
  11. In article <>,
    Roedy Green <> wrote:

    > On Mon, 21 Jun 2004 08:57:00 -0400, Phillip Mills
    > <> wrote or quoted :
    >
    > >It's true that sometimes people post questions based on strategies that
    > >are full of holes, but to start by *assuming* that's the case strikes me
    > >as rude and ignorant.

    >
    > On the other hand you exude entitlement which many find even more
    > irritating than arrogance. Nobody OWES you any answer at all, much
    > less one in the form you desire.


    I have seen people who try to insist on receiving an answer from a
    newsgroup and who become irate when no one answers their (often
    off-topic) question. I don't do that and since I specifically said,
    "silence is always an acceptable response," I don't get where your
    'entitlement' insult is coming from. How about you wait until I ask
    something before judging whether I show enough gratitude for responses?

    > If someone makes any stab at answering your question, they are trying
    > to be as helpful as they can. The alternative would be to hold back
    > the little info they can and leave you in the dark. If even there is a
    > 10% chance the answer could prove useful, I'd think you would feel
    > grateful they tool the time to share that information. Most people
    > ignored you entirely.


    I agree with that paragraph completely.

    I have no problem with partial answers, tentative answers, RTFM answers,
    wrong answers, or no answers. I do have a problem with those who
    dismiss questions as meaningless, irrelevant, stupid, or not legitimate
    so that they can demonstrate their own shining excellence.

    > If you want to control the way people answer you, you will have to pay
    > them.


    (Actually, paying people for expertise and then trying to control how
    they answer your questions is a good recipe for wasting money. OTOH, if
    they try to redefine your business without understanding it....)

    --
    Phillip Mills
    Multi-platform software development
    (416) 224-0714
    Phillip Mills, Jun 22, 2004
    #11
  12. whois

    Roedy Green Guest

    On Tue, 22 Jun 2004 08:46:55 -0400, Phillip Mills
    <> wrote or quoted :

    >I agree with that paragraph completely.


    you did not come across that way.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 22, 2004
    #12
  13. whois

    Roedy Green Guest

    On Tue, 22 Jun 2004 08:46:55 -0400, Phillip Mills
    <> wrote or quoted :

    > I do have a problem with those who
    >dismiss questions as meaningless, irrelevant, stupid, or not legitimate
    >so that they can demonstrate their own shining excellence.


    That is reasonable. But what it sounded originally like you were
    saying is that people have no business trying to redefine your
    problem.

    You were treating those sorts of answers as insults rather than
    unwanted gift horses.

    The problem is you have to accept the chaff with the wheat. Even
    arrogant assholes can be useful if you can ignore the packaging.

    There are a multitude of reasons people are willing to help you for
    free.

    They may be religious (see http://mindprod.com/ccism.html for mine),
    to feel helpful or worthy, to gain admiration, to scare up business,
    to find people to insult who can't hit back, pathological curiosity,
    procrastination, checking out information -- knowing others will shoot
    it down if it is wrong.

    The point to always remember is that you have no entitlement of any
    kind to an answer, much less in the form you want. EVERYTHING you get
    is a free bonus. Ever see the movie Brother Sun and Sister Moon? when
    St. Francis of Assisi thanks people for throwing garbage on him -- he
    needs the food. That's a bit like what happens when you ask a question
    in a newsgroup.



    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 22, 2004
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alessandro

    Problems with Dinamic controls

    Alessandro, Jul 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    403
    Cristian Suazo
    Jul 16, 2003
  2. Damir

    Dinamic images

    Damir, May 6, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    371
    Damir
    May 6, 2005
  3. Novello

    dinamic classloader?

    Novello, Jul 1, 2005, in forum: Java
    Replies:
    3
    Views:
    332
    Chris Smith
    Jul 1, 2005
  4. Roberto Dias
    Replies:
    1
    Views:
    737
    Paolo Alexis Falcone
    Jun 30, 2004
  5. Morgan
    Replies:
    7
    Views:
    442
    CBFalconer
    Feb 7, 2004
Loading...

Share This Page