Click to See Complete Forum and Search --> : Learn about Java 5(Java 1.5)....


a0060193723186
January 30th, 2004, 04:32 AM
:wave: Hi guys is ther anything like Java 5(1.5) which Sun is going to release shortly n which would change the Programming World:mad: ? Coz my tells frequently about that thing . "java5 is going to come , which is going to be completly from what u r seeing, using, prgramming." .confussing me. Plz let me know if there is anything like that.:lol:

dlorde
January 30th, 2004, 08:23 AM
The biggest change for programmers in J2SE 1.5 will be generics (similar to C++ templates). There will also be autoboxing and unboxing (implicit conversions between basic types and their class implementations), typesafe enums, enhanced 'for' loop, static imports, and metadata.

Why not see for yourself? New Language Features for Ease of Development in the Java 2 Platform, Standard Edition 1.5 (http://java.sun.com/features/2003/05/bloch_qa.html).

The structure of a system reflects the structure of the organization that built it...
R. Fairley

Joe Nellis
January 30th, 2004, 12:56 PM
The enums look interesting. I see though that generics and autoboxing are pretty much straight C++ features. As someone who does both, I see this as a great idea. The 'enhanced' for loop thing though is a minor breakthrough/annoyance. I will probably not use it but I now must remember it so I can read others code.

The last two features, static member importing and metadata seem geared toward IDE users where most of them now have those popups to navigate the class heirarchy. I usually can't remember all the members of a class unless I have one of these helpers but I know that seeing the class prefix in the code helps me remember at least that "so and so object" has such a member. I guess this boils down to an out of sight, out of mind thing. If you static import methods from multiple classes and someone else tries to read your code, how will they know which static object a particular method comes from? This will also simplify the amount of autocode that IDE's produce maybe.

dlorde
January 30th, 2004, 01:21 PM
Yes, I have my doubts about the usefulness of static imports and metadata, especially metadata. It seems to me they're trying to make Java into a C# clone. ISTM that metadata means pre-processing comments (or 'annotations' as they call them in the explanation), which adds a whole mess of complications that Java was originally designed to avoid at all costs...

I guess we'll have to wait and see what comes...

Joe Nellis
January 30th, 2004, 06:43 PM
What would be useful in my opinion is a marker or something shown at member declaration that implies that the get/set bean pattern be applied to this member. If they are gonna stick a colon in a for statement then lets go hog wild. Get/Set functions are the biggest eyesore out there.


public class MyObject{

protected <> int val1; // get and set priveleges
protected < int val2; // get only
protected > int val3; // set only
protected int val4; // no implied getter or setter.
// Capitalize first letter of object name and append
// as suffix to either get or set method.

public static void main(String[] args){
public MyObject myob;
myob.getVal1(int val);
myob.getVal2(int val);
myob.setVal3(int val);
myob.setVal4(int val); // compile error
}

}

ArchAngel
January 30th, 2004, 07:06 PM
You must be a C++ programmer....nice syntax....yuck! ;-)

It may interest you to know that there is an @property attribute.

dlorde
January 31st, 2004, 11:06 AM
Originally posted by Joe Nellis
What would be useful in my opinion is a marker or something shown at member declaration that implies that the get/set bean pattern be applied to this member. If they are gonna stick a colon in a for statement then lets go hog wild. Get/Set functions are the biggest eyesore out there...The problem is that the reason for making data private and implementing getters and setters seems to have been forgotten. The principle is that when the data is properly encapsulated, its internal representation doesn't matter and, in particular, can be changed - without affecting any calling code. Further, controlling access via getters and setters enables tracking and validation to be transparently managed inside the class. Once you start automatically generating getters and setters, you start on the slippery slope of then needing more automatic generation facilities to handle validation, tracking, and debugging of data access. The result is a mishmash of Java code and whole mess of 'annotations' that will always be restricted compared to manually implementing a method, and will still often require manually implemented methods for cases that auto-generated code just can't manage - and, of course, you still don't get the primary encapsulation advantage of being able to change the internal data representation without affecting callers.

True, for value classes that simply pass data around, primitive getters and setters are all that is required, but modern IDEs can generate the methods for getters and setters without compromising their flexibility or introducing any annotations that generate hidden code.

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning...Rich Cook

Joe Nellis
January 31st, 2004, 11:47 AM
Yes, my netbeans IDE does bean pattern generation nicely if you ask it and swing a chicken above your head 3 times. I see the IDE's taking on the filler portion of enhancing the language but the typical IDE prefers to be verbose when generating this autocode (including 3 to 4 lines for stupid comment tags).

Maybe a better idea is to have some kind of minor intelligence in the IDE that knows to spit out


public String get_currentWord() { return _currentWord; }
public void set_currentWord(String _currentWord) { this._currentWord = _currentWord; }

instead of this
/** Getter for property _currentWord.
* @return Value of property _currentWord.
*
*/
public java.lang.String get_currentWord() {
return _currentWord;
}

/** Setter for property _currentWord.
* @param _currentWord New value of property _currentWord.
*
*/
public void set_currentWord(java.lang.String _currentWord) {
this._currentWord = _currentWord;
}

ArchAngel
January 31st, 2004, 02:09 PM
Change your IDE Joe, you should be able to specify the format of the generated code - mine does (odd use of _ character BTW).

Joe Nellis
January 31st, 2004, 08:28 PM
I will look next time. I'm using netbeans. I used to use the Sun Studio before it was called studio. It's basically netbeans but all the extra crap Sun put in it just bogs down the cpu. I find netbeans is not as buggy as Studio (maybe due to extra bells and whistles). I will admit to using visual J++ in my java youth only because like netbeans, it was free for me.

Free Free Free.
I know no other IDE.

Ignore that underscore, its from anothers code. I just needed some IDE output from the BeanPatternSuperGetterSetterFunctionWriterThingy.

cjard
February 2nd, 2004, 07:43 AM
roll on visual basic!

"for each item in JCombobox1.items...."

okay, it's useful to avoid nullpointers, but as far as i can see, it only goes forward?

for(int i = array.length; i>=0; i--)

is still going to find a home.. and then you have 2 different styles of for loop...where did code readbility through consistency go?

why didnt they just declare a new keyword?

String[] myStrings;
iterate(aString: mystrings){
...
}

dlorde
February 2nd, 2004, 08:18 AM
Originally posted by cjard
why didnt they just declare a new keyword?They didn't want to break existing code that might be using the keyword as a name, and they thought it would be cool to use a symbol...

Any sufficiently advanced bug is indistinguishable from a feature...
Bruce Brown

ArchAngel
February 2nd, 2004, 09:41 AM
Personally, I'm glad we've finally got a foreach loop (I'm never going to call it "an enhanced for loop"). I get sick of writing common boilerplate code all the time...