java needs typedef

Discussion in 'Java' started by Steve Green, Mar 24, 2005.

  1. Steve Green

    Steve Green Guest

    I was just doing a bit of coding for Java 1.5 and using generics; I am
    rewriting an application I developed using the new features. I said it
    before they implemented generics that they needed typedef and now that we
    have generics I say again ... we need typedef ...

    Which is really worse having to cast a return value on occasion or defining
    HashMap<Key,Class> var = new HashMap<Key,Class>();

    I try to use descriptive class names so they are longer than this.

    We should be able to define an alias to Generic types.
    For example:
    typedef HashMap<Key,Class> MyHashMap;

    Just a little frustrated,
    Steve
     
    Steve Green, Mar 24, 2005
    #1
    1. Advertising

  2. Steve Green

    AJ M. Guest

    dont be lazy. It is bad enough they added generics and autoboxing to Java.
    It's beauty was in its simplicity.


    "Steve Green" <> wrote in message
    news:5Un0e.34298$FB6.12790@trndny09...
    > I was just doing a bit of coding for Java 1.5 and using generics; I am
    > rewriting an application I developed using the new features. I said it
    > before they implemented generics that they needed typedef and now that we
    > have generics I say again ... we need typedef ...
    >
    > Which is really worse having to cast a return value on occasion or

    defining
    > HashMap<Key,Class> var = new HashMap<Key,Class>();
    >
    > I try to use descriptive class names so they are longer than this.
    >
    > We should be able to define an alias to Generic types.
    > For example:
    > typedef HashMap<Key,Class> MyHashMap;
    >
    > Just a little frustrated,
    > Steve
    >
    >
     
    AJ M., Mar 24, 2005
    #2
    1. Advertising

  3. Steve Green

    Jeff Schwab Guest

    AJ M. wrote:
    > dont be lazy. It is bad enough they added generics and autoboxing to Java.
    > It's beauty was in its simplicity.


    I don't believe the issue is one of "laziness." It's one of clarity and
    abstraction.

    Of course, language changes are inherently Evil. What alternatives to
    typedef are available already? I would appreciate suggestions from this
    community. Why was typedef not brought into the language along with
    generics?


    > "Steve Green" <> wrote in message
    > news:5Un0e.34298$FB6.12790@trndny09...
    >
    >>I was just doing a bit of coding for Java 1.5 and using generics; I am
    >>rewriting an application I developed using the new features. I said it
    >>before they implemented generics that they needed typedef and now that we
    >>have generics I say again ... we need typedef ...
    >>
    >>Which is really worse having to cast a return value on occasion or

    >
    > defining
    >
    >>HashMap<Key,Class> var = new HashMap<Key,Class>();
    >>
    >>I try to use descriptive class names so they are longer than this.
    >>
    >>We should be able to define an alias to Generic types.
    >>For example:
    >>typedef HashMap<Key,Class> MyHashMap;
    >>
    >>Just a little frustrated,
    >>Steve
    >>
    >>

    >
    >
    >
     
    Jeff Schwab, Mar 24, 2005
    #3
  4. I agree.

    By the same logic as the original thread, one could say that any high level
    language is also a matter of "laziness" when compared to assembly language.
    No one certainly needs a language like C++ or Java or C# when it all gets
    compiled/interpreted to machine code in the end.

    I come from .NET and have just begun learning Java. Although some of the
    constructs are different, .NET has come real conveniences that are working
    their way into the Java world, and vis versa.

    In the end, the evolution of software and languages make for a better
    development environment where we are all more productive.

    "Jeff Schwab" <> wrote in message
    news:...
    > AJ M. wrote:
    > > dont be lazy. It is bad enough they added generics and autoboxing to

    Java.
    > > It's beauty was in its simplicity.

    >
    > I don't believe the issue is one of "laziness." It's one of clarity and
    > abstraction.
    >
    > Of course, language changes are inherently Evil. What alternatives to
    > typedef are available already? I would appreciate suggestions from this
    > community. Why was typedef not brought into the language along with
    > generics?
    >
    >
    > > "Steve Green" <> wrote in message
    > > news:5Un0e.34298$FB6.12790@trndny09...
    > >
    > >>I was just doing a bit of coding for Java 1.5 and using generics; I am
    > >>rewriting an application I developed using the new features. I said it
    > >>before they implemented generics that they needed typedef and now that

    we
    > >>have generics I say again ... we need typedef ...
    > >>
    > >>Which is really worse having to cast a return value on occasion or

    > >
    > > defining
    > >
    > >>HashMap<Key,Class> var = new HashMap<Key,Class>();
    > >>
    > >>I try to use descriptive class names so they are longer than this.
    > >>
    > >>We should be able to define an alias to Generic types.
    > >>For example:
    > >>typedef HashMap<Key,Class> MyHashMap;
    > >>
    > >>Just a little frustrated,
    > >>Steve
    > >>
    > >>

    > >
    > >
    > >
     
    Peter Rilling, Mar 24, 2005
    #4
  5. Steve Green

    Malte Guest

    AJ M. wrote:
    >
    > It's beauty was in its simplicity.
    >

    I totally agree.
     
    Malte, Mar 24, 2005
    #5
  6. AJ M. wrote:
    > It's beauty was in its simplicity.


    Yes, it was. And then they decided to add some pet syntax, because
    <voice style="parody" type="old lady">
    "it is so much nicer" :-(
    </voice>

    All this has nothing to do with evolution of the state of the art. Java
    has become part of the usual language "enhancement" cycle. A language is
    "enhanced" up to the point were someone comes and says enough is enough
    and creates something simpler. Then this new simpler language starts
    being "enhanced" over time up to the point were it is at least as
    complex as the predecessor. At that point yet another new simple
    language comes up ...



    /Thomas

    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
     
    Thomas Weidenfeller, Mar 24, 2005
    #6
  7. "Steve Green" <> writes:

    > HashMap<Key,Class> var = new HashMap<Key,Class>();


    That is nothing. Using the wildcard variants for generics is the real
    pain, and typedef won't help there.
     
    Tor Iver Wilhelmsen, Mar 24, 2005
    #7
  8. "Steve Green" <> ¼¶¼g©ó¶l¥ó·s»D:5Un0e.34298$FB6.12790@trndny09...
    >I was just doing a bit of coding for Java 1.5 and using generics; I am
    >rewriting an application I developed using the new features. I said it
    >before they implemented generics that they needed typedef and now that we
    >have generics I say again ... we need typedef ...
    >
    > Which is really worse having to cast a return value on occasion or
    > defining
    > HashMap<Key,Class> var = new HashMap<Key,Class>();
    >
    > I try to use descriptive class names so they are longer than this.
    >
    > We should be able to define an alias to Generic types.
    > For example:
    > typedef HashMap<Key,Class> MyHashMap;
    >
    > Just a little frustrated,
    > Steve


    Instead of using typedef, just use inheritence :

    public class MyHashMap extends HashMap<Key,Class>
    {
    }

    ... and that's it.

    Vincent
     
    Vincent Cantin, Mar 25, 2005
    #8
  9. "Tor Iver Wilhelmsen" <>
    ???????:...
    > "Steve Green" <> writes:
    >
    >> HashMap<Key,Class> var = new HashMap<Key,Class>();

    >
    > That is nothing. Using the wildcard variants for generics is the real
    > pain, and typedef won't help there.


    An example, please ?
     
    Vincent Cantin, Mar 25, 2005
    #9
  10. Steve Green

    Tim Tyler Guest

    AJ M. <> wrote or quoted:

    > dont be lazy. It is bad enough they added generics and autoboxing to Java.
    > It's beauty was in its simplicity.


    Java was never simple.

    In that respect it resembles English - full of
    difficult-to-learn irregularities, and exceptions.

    The designers chose to borrow from C++ rather than Smalltalk in that area.
    --
    __________
    |im |yler http://timtyler.org/ Remove lock to reply.
     
    Tim Tyler, Mar 25, 2005
    #10
  11. "Vincent Cantin" <> writes:

    > "Tor Iver Wilhelmsen" <>
    > ???????:...
    > > "Steve Green" <> writes:
    > >
    > >> HashMap<Key,Class> var = new HashMap<Key,Class>();

    > >
    > > That is nothing. Using the wildcard variants for generics is the real
    > > pain, and typedef won't help there.

    >
    > An example, please ?


    I think what I was really thinking of was bounded types.

    HashMap<? extends Key, ? extends Class> var = new HashMap<Key,Class>();

    The advantage over your version is that var can be assigned a map with
    parametrized types that aren't exactly Key or Class.

    Also for parametrized methods:

    public <L extends List<? extends Element>> L merge(L list1, L list2) {
    ....
    }
     
    Tor Iver Wilhelmsen, Mar 25, 2005
    #11
  12. [OT] java needs typedef

    AJ M. <> scribbled the following:
    > It's beauty was in its simplicity.


    It's common to see "its" misspelled, but not as common to see it spelled
    both wrong and right in the same sentence.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-------------------------------------------------------- rules! --------/
    "B-but Angus! You're a dragon!"
    - Mickey Mouse
     
    Joona I Palaste, Mar 25, 2005
    #12
    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. Edu
    Replies:
    1
    Views:
    338
  2. John Grogan

    Non Java programmer needs help!!

    John Grogan, Oct 1, 2003, in forum: Java
    Replies:
    2
    Views:
    335
    John Grogan
    Oct 2, 2003
  3. PaulG
    Replies:
    1
    Views:
    613
    PaulG
    Feb 28, 2004
  4. oor
    Replies:
    0
    Views:
    1,396
  5. sarah Fernandes
    Replies:
    0
    Views:
    352
    sarah Fernandes
    Mar 9, 2011
Loading...

Share This Page