Any tool to convert java raw code (a la java 1.4) into generics code

Discussion in 'Java' started by Royan, Feb 13, 2008.

  1. Royan

    Royan Guest

    Hi all,

    I wonder if someone has ever tried to convert Java 1.4 style code into
    code that is using generics? What tools did you use and what was your
    overall experience?

    Thanks Roman.
    Royan, Feb 13, 2008
    #1
    1. Advertising

  2. Royan

    Roedy Green Guest

    On Wed, 13 Feb 2008 06:34:56 -0800 (PST), Royan <>
    wrote, quoted or indirectly quoted someone who said :

    >I wonder if someone has ever tried to convert Java 1.4 style code into
    >code that is using generics? What tools did you use and what was your
    >overall experience?


    Just put the generics on the declare and the allocations. Compile. Fix
    the errors. Run IntelliJ inspector and it will tell point you to the
    places to pull the casts.

    USING generic classes is a snap once you get the hang of it. You can
    convert a program is a few minutes. The tricky part is writing a
    Collections class. There you do it by monkey-see-monkey do looking
    for a similar collection.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Feb 13, 2008
    #2
    1. Advertising

  3. Royan

    Daniel Pitts Guest

    Re: Any tool to convert java raw code (a la java 1.4) into genericscode

    Roedy Green wrote:
    > On Wed, 13 Feb 2008 06:34:56 -0800 (PST), Royan <>
    > wrote, quoted or indirectly quoted someone who said :
    >
    >> I wonder if someone has ever tried to convert Java 1.4 style code into
    >> code that is using generics? What tools did you use and what was your
    >> overall experience?

    >
    > Just put the generics on the declare and the allocations. Compile. Fix
    > the errors. Run IntelliJ inspector and it will tell point you to the
    > places to pull the casts.
    >
    > USING generic classes is a snap once you get the hang of it. You can
    > convert a program is a few minutes. The tricky part is writing a
    > Collections class. There you do it by monkey-see-monkey do looking
    > for a similar collection.

    Programming should *never* be monkey-see-monkey-do! If you don't
    understand what you're writing, then you're probably making a bug.
    > --
    >
    > Roedy Green Canadian Mind Products
    > The Java Glossary
    > http://mindprod.com



    --
    Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
    Daniel Pitts, Feb 13, 2008
    #3
  4. Re: Any tool to convert java raw code (a la java 1.4) into genericscode

    Daniel Pitts wrote:
    > Roedy Green wrote:
    >> On Wed, 13 Feb 2008 06:34:56 -0800 (PST), Royan <>
    >> wrote, quoted or indirectly quoted someone who said :
    >>
    >>> I wonder if someone has ever tried to convert Java 1.4 style code into
    >>> code that is using generics? What tools did you use and what was your
    >>> overall experience?

    >>
    >> Just put the generics on the declare and the allocations. Compile. Fix
    >> the errors. Run IntelliJ inspector and it will tell point you to the
    >> places to pull the casts.
    >>
    >> USING generic classes is a snap once you get the hang of it. You can
    >> convert a program is a few minutes. The tricky part is writing a
    >> Collections class. There you do it by monkey-see-monkey do looking
    >> for a similar collection.


    > Programming should *never* be monkey-see-monkey-do! If you don't
    > understand what you're writing, then you're probably making a bug.


    OTOH I find reading examples can be a useful way of arriving at a better
    understanding.

    According to Wikipedia monkey-see-monkey-do means different things in
    different locales.
    RedGrittyBrick, Feb 14, 2008
    #4
  5. Royan

    Jack Guest

    Re: Any tool to convert java raw code (a la java 1.4) into genericscode

    Royan a écrit :
    > Hi all,
    >
    > I wonder if someone has ever tried to convert Java 1.4 style code into
    > code that is using generics? What tools did you use and what was your
    > overall experience?


    In eclipse, select your project, right click on it, and then Refactor -> Infer Generic Type Arguments...

    I guess you will have to check/correct some piece by hand, but most of it will be done automaticaly, depending how complexe is the code.
    Jack, Feb 14, 2008
    #5
  6. Royan

    Daniel Pitts Guest

    Re: Any tool to convert java raw code (a la java 1.4) into genericscode

    RedGrittyBrick wrote:
    > Daniel Pitts wrote:
    >> Roedy Green wrote:
    >>> On Wed, 13 Feb 2008 06:34:56 -0800 (PST), Royan <>
    >>> wrote, quoted or indirectly quoted someone who said :
    >>>
    >>>> I wonder if someone has ever tried to convert Java 1.4 style code into
    >>>> code that is using generics? What tools did you use and what was your
    >>>> overall experience?
    >>>
    >>> Just put the generics on the declare and the allocations. Compile. Fix
    >>> the errors. Run IntelliJ inspector and it will tell point you to the
    >>> places to pull the casts.
    >>>
    >>> USING generic classes is a snap once you get the hang of it. You can
    >>> convert a program is a few minutes. The tricky part is writing a
    >>> Collections class. There you do it by monkey-see-monkey do looking
    >>> for a similar collection.

    >
    >> Programming should *never* be monkey-see-monkey-do! If you don't
    >> understand what you're writing, then you're probably making a bug.

    >
    > OTOH I find reading examples can be a useful way of arriving at a better
    > understanding.

    Agreed. Acceptable for training for programming. Not production
    programming.
    >
    > According to Wikipedia monkey-see-monkey-do means different things in
    > different locales.

    But they both involve mimicry without understanding.

    --
    Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
    Daniel Pitts, Feb 14, 2008
    #6
  7. Royan

    Roedy Green Guest

    On Wed, 13 Feb 2008 15:18:23 GMT, Roedy Green
    <> wrote, quoted or indirectly quoted
    someone who said :

    > There you do it by monkey-see-monkey do looking
    >for a similar collection.


    What I meant by that is you can copy techniques without going to the
    work of creating them from scratch. You have to understand them only
    weakly -- knowing what the syntax means, without necessarily
    developing the skill to compose them.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Feb 15, 2008
    #7
  8. Royan

    Royan Guest

    Re: Any tool to convert java raw code (a la java 1.4) into genericscode

    Ok, thank you everyone! I was also wondering what other people think
    about this and I guess I got the common point :)
    Royan, Feb 15, 2008
    #8
  9. Re: Any tool to convert java raw code (a la java 1.4) into genericscode

    Jack wrote:
    > Royan a écrit :
    >> Hi all,
    >>
    >> I wonder if someone has ever tried to convert Java 1.4 style code into
    >> code that is using generics? What tools did you use and what was your
    >> overall experience?

    >
    > In eclipse, select your project, right click on it, and then Refactor ->
    > Infer Generic Type Arguments...
    >
    > I guess you will have to check/correct some piece by hand, but most of
    > it will be done automaticaly, depending how complexe is the code.
    >
    >


    However, in my experience it works much better if the programmer has
    some experience with generics.

    I tried that technique shortly after I moved to 1.5, and got in such a
    muddle that I had to revert out the changes and live with the warnings.

    A few months later, I tried again on the same program and it all went
    through very smoothly.

    The difference was that I had been using generics in new code and
    reading about them. During the first attempt, I was essentially
    guessing, and making a lot of wrong choices, when Eclipse did not know
    what to do. During the second attempt, I knew what I was doing.

    Patricia
    Patricia Shanahan, Feb 15, 2008
    #9
    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. dee
    Replies:
    6
    Views:
    9,212
  2. Thomas G. Marshall

    1.5: generics warning of using Raw datatype

    Thomas G. Marshall, Aug 17, 2004, in forum: Java
    Replies:
    7
    Views:
    21,662
    knightpraetor
    Jun 11, 2011
  3. Juergen Berchtel
    Replies:
    1
    Views:
    5,973
    John C. Bollinger
    May 20, 2005
  4. Sebastien B.
    Replies:
    1
    Views:
    595
  5. Soul
    Replies:
    0
    Views:
    508
Loading...

Share This Page