Re: Why Generics?




"David Blickstein" <db@xxxxxx> wrote in message
news:oMOee.5020$Eq1.1426@xxxxxxxxxxxxxxxxxxx
>> My reason is simply that people have been discussing adding "templates"
>> to
> Java
>> since well before C# was invented (or at least publicly admitted to).
> Same
>> goes for enums.
>
> Enums were truly needed. They eliminated a class of (what I consider to
> be)
> type-related errors that in my experience was very common: using the wrong
> constant in the wrong context. Like substituting LAYOUT.LEFT_JUSTIFIED
> for LAYOUT.WEST in a layout manager.
>
> There's a C# feature that I also think is desperately needed in Java.
>
> C# allows you to use the SAME syntax for fields and nyladic (zero
> arguments)
> methods. This allows you to abstract the implementation of the field so
> that fields can be re-implemented as methods without breaking existing
> code.

A syntax change doesn't help much here. Unless the bytecode is also changed
to make field references and zero-argument method calls identical, a change
will cause incompatibility with existing binaries.


.



Relevant Pages

  • Re: Scala
    ... durch das Hinzufuegen von Enums zu den primitiven Typen als erlaubte ... sealed trait AndOrEnum extends Function2[Boolean, Boolean, Boolean] ... Steuerungskonstrukt wie in Java.) ...
    (de.comp.lang.java)
  • Re: Why default parameter values where not included in Java
    ... >>to find what you're looking for then the following Java overloaded ... >>int ShowMessage(string MainMsg, string Title, int MessageType, int ... > can be achieved with method overloading, and method overloading was going to ... It's fun to read why the didn't include enums. ...
    (comp.lang.java.programmer)
  • Re: XML parsing with Java
    ... We found this out after writing a few thousand lines with generics, enums, and a few other 1.5 features. ... If I had the ears of the decision makers where I work, I'd suggest to them that the risk of continuing with Java 1.4, with its insufficient concurrent memory model and slower performance than modern versions, exceeds that of the conversion to Java 5, especially in our environment which involves multiple nodes with multiple processors running multiple JVMs with various forms of communication between them processing high peak volumes of information per unit of time under tight time constraints and rigorous availability requirements. ... The fear of upgrade that I've witnessed was based on considerations of product reliability on a new platform, cost of code conversions, and operations costs associated with migration to and maintenance of the new enterprise platform. ...
    (comp.lang.java.programmer)
  • Re: compare with empty string uses equals method or == ??
    ... > int for a somewhat safe usage, as a compromise in absence of enums. ... Sun Certified Developer for the Java 2 Platform ...
    (comp.lang.java.programmer)

Loading