Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 958924

Pages: 1 | 2 | >> (show all)
JavaWorld
addict


Reged: 06/20/03
Posts: 482
Taming Tiger, Part 1
      #6505 - 04/25/04 12:24 AM

Taming Tiger, Part 1

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Taming Tiger, Part 1 [Re: JavaWorld]
      #6548 - 04/26/04 11:59 AM

Nice!

Post Extras: Print Post   Remind Me!   Notify Moderator  
GPX
Unregistered




bool ? [Re: JavaWorld]
      #6584 - 04/27/04 04:41 AM

In the boxing table on page 1, the first element of the 'Primitive Type' row is 'bool'. Shouldn't this be 'boolean'

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Goodbye Duke! [Re: JavaWorld]
      #6620 - 04/27/04 02:33 PM

Quoting:
"To be completely honest, none of these features introduce any groundbreaking or previously impossible functionality into the Java language."
- And to be extremely honest, who on earth felt the need of the new 'for' sintax? Why change something that all the world is used to since epoch??
"the new features do provide are reduced code complexity, enhanced readability..."
- What???Increase readability?With all those funny sintax that allows to save a couple of words? And at what cost?
I agree with you about enum, but were they so "important" to call this new 1.5 release the biggest enancement since ever???
I'm telling what I really think. Java will get closer and closer to C#, until one day only vm for windows will be supported. At that point Java will change name into "C super" and Uncle Bill will celebrate. With 2 billion of dollars he got Sun at his knee and transformed millions of developers into supporters of his os!
Goodbye Duke, it has been a wonderful adventure being together, but someone has sold you for 30 coins!
Let's celebrate new release!

dylan68@mail.com


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Taming Tiger, Part 1 [Re: Anonymous]
      #6621 - 04/27/04 02:51 PM

Good catch... it should be boolean (not bool). It is a typo on my part and a side effect of going back and forth between Java and C#.

- Tarak.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: bool ? [Re: GPX]
      #6622 - 04/27/04 02:53 PM

Good catch... it should be boolean (not bool). It is a typo on my part and a side effect of going back and forth between Java and C#.

- Tarak.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Readability suffers [Re: Anonymous]
      #6648 - 04/27/04 11:15 PM

One of the reasons why I liked programming in Java was that Java always had to force me into making my code more readable. I wasn't free to whatever I liked; I had to follow Java's rules even if it meant more typing to get the job done.

1) Boxing, unboxing
I have mixed feelings about this. It'll definitely make my life as a code writer easier with the primitives, but what about my life as a code reader? Upon seeing other people's code, would I immediately think "this method always uses an int"?

2) Enhanced for loop
As said, the unenhanced for loop is "cumbersome", but for whom? The code writer, or programmer, of course! If I were a stupid code reader, I have to know explicitly that the collection is unmodifiable. It's a classic case of whether to trust the language or trust the API.

3) Variable method arguments and printf
Yes, there were many times back then when I asked "why oh why am I stuck using a fixed number of arguments?" I had to use workarounds to get around that "limitation". I usually ended up with more elegant solutions afterwards, solutions that were more robust because they were planned with the future in mind. That's one odd thing about good ideas: if necessity is the mother of invention, limitation is the mother of creativity.

4) Enumerations
Personally, I'm still confused about enumerations. Will they fit into the class heirarchy and get their own class files? I guess I better read up on Tiger then. (^_^) In the past, I used classes with private constructors; e.g.

Code:

public interface Switchable {

public class Mode {

private String mode_description;

private Mode(String mode_description) {
this.mode_description = mode_description;
}

public void append_to_string_buffer(StringBuffer buffer) {
buffer.append(this.mode_description);
}

}

public abstract final Switchable.Mode SWITCH_ON = new Switchable.Mode("this switch is on");

public abstract final Switchable.Mode SWITCH_OFF = new Switchable.Mode("this switch is off");

public abstract void switch_mode(Switchable.Mode mode);
public abstract Switchable.Mode get_mode();

}




It's nice for me because I can return to this code in six months even though I've forgotten all about it. A quick read is all it takes for me to know that my "enumeration" is intimately tied to the use of an interface.

5) Static imports
I'm not too hot on this, either. When I program, I don't leave off the fixtures in front of the variables; it helps the readers of my code determine from where the variable comes. For instance, if I use "this.variable", the code reader can automatically differentiate it from variables without the reference to "this".
In a way, it makes it easier for the reader to know whether the variable is local or not. Same goes for static. I love putting the classname in front (it was obligatory in the past) because it's an automatic flag for code scanners, people who didn't originally write the code but have to read code fast because they are either too busy to actually read the whole code throughout or have to fix a bug within five minutes.

It's all about readability. Shortcuts aren't really the solution; if they were, Java would have preprocessors by now! (^_^)


Post Extras: Print Post   Remind Me!   Notify Moderator  
Victor_H
journeyman


Reged: 05/02/04
Posts: 93
Loc: Santiago, Chile
Re: Readability suffers
      #6839 - 05/03/04 01:35 PM

I hope that this new stuff, does not deprecate the other forms in Java.... Oops! .. hope again, that I didn't gave new ideas to the guys at the JCP, 'cause that would suck

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Readability suffers [Re: Anonymous]
      #7693 - 06/09/04 04:50 AM

I definitely agree with #1 and #5.
I somehow agree with the risk of #3 but I think variable arguments are useful and can improve readability in some situation.

But I side with JCP on enhanced loop and enumeration. The oridinary way produces a lot of irrelevant codes for both the writers to write and the readers to read.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Readability suffers [Re: Anonymous]
      #9437 - 07/20/04 08:39 AM

I so agree with #5.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Readability suffers [Re: Anonymous]
      #9464 - 07/20/04 03:35 PM

Agree 100%, except for enums.
Looks like Java lost to the Lazy C coder,
who still hasn't learned to TYPE.
Sheeese...

God, the printf statement, that piece of crap back in the language. Looks like we've got to drag the lazy C/C++ programmers who don't want to learn a damn new thing.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Readability suffers
      #9465 - 07/20/04 03:39 PM

Learn to type, then you can easily use a language that requires you to explicitly code correctly.

AutoBoxing is going to lead to hidden problems, just like in Microsoft's vb 6 and unwanted variant auto-conversions with no type checking.

1.5 looks like Java Dumbed down for the Lazy.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Daniel Barbalace
Unregistered




Some good, some bad [Re: Anonymous]
      #15726 - 02/22/05 02:36 PM

1) Boxing, unboxing
> I have mixed feelings about this...
I agree. It's not particularly good or bad. It's a minor convenience in typing and reader offsetted by a minor inconvenience of having to know a little "gotcha".

2) Enhanced for loop
> As said, the unenhanced for loop is "cumbersome", ...
I disagree. The enhanced for loop is a good concept. Do we need another loop construct? No, we only need one, but we have three: for, while, do-while. The only problem with the enhanced for loop is its syntax. It should have been constructed like this:

for each String name in myCollectionOfNames

It would be more readable like the C# foreach. I would have like to see a space between the for and the each, making them separate reserve words. As for reserve words being expensive, that's marketing b.s. Java has had the unused reserve word goto since its inception. They probably didnt want it to look like Java was stealing an idea from C#. I say why not? C# stole all of its ideas from Java. Come to think of it, Java stole many ideas from SmallTalk. Thats the nature of the evolution of programming languages. You throw out the bad, and keep the good.

3) Variable method arguments and printf
> [Paraphrasing: both are bad]
I agree that variable number arguments are unnecessary and always a worse solution that what you would come up with as an alternative. You can use an array of objects, a hashmap, a collection, etc. These solutions always end up being more readable than a variable number of arguments. I think the main reason the variable number of arguments was added was to support printf (just like in C).

As for the printf method itself, I don't mind that so much. You rarely want to do console output unless you're throwing together some temporary code. Even logging is better done through an API. Most often I'll continue to use the print and println methods, but it doesn't do any harm to have a formatted printing method for those times that you are writing throw-away code.

4) Enumerations
> Personally, I'm still confused about enumerations...
Enumerations should be considered a special kind of class, like arrays are. You can always write a generic enumeration class that has all the functionality of the Java 1.5 or C# enumeration construction including type safety and converting the ordinal value to a string automatically. However, the price has always been efficiency. Since you can't write VM code directly in source code (although there are ways around that), the performance and memory requirements are always much more than for ints.

The great thing about the enumeration construct is that, at least in principle, the enumerations can be accessed as quickly as ints and the text equivalent of the ordinal value can be accessed as quickly as a static string. Hopefully, the actual implementation is close to this ideal.

Enumerations should have been in JDK 1.0. The original Java team left some C/C++ things out because they wanted to make sure there was only one way to accomplish things: the best way. In general, this is a very good principle. However, there is always a little disagreement as to what constitutes the best way. Enumerations offer range check, type safety, and readability. That's why they should have been in Java from the beginning. The other stuff left out of Java was probably for the best...

The one thing we need is a way to systematically Javadoc enumerations. With final static int fields, you can Javadoc each field to describe its meaning in detail. Is there a way to do this with enumerations without having to add a <p> tag or equivalent in your class documentation? Granted, for enum Color {red, green, blue} thats not important. But it is important for enum OracleSqlExceptionCode {}. It would be nice to be able to do

enum XmlExceptionCode
{
/** Indicates that the given node cannot be added to the tree at the current location. This commonly occurs because the given nodes type does not match the types allowed by the XML schema. */
nodeCannotBeAdded,

/** Indicates that no node with the given value of the id attribute was found in this XML tree */
idNotFound
}

One final thought on enumerations. Which convention should everyone adopt? enum Color {red, green, blue}; enum Color (Red, Green, Blue); or enum Color (RED, GREEN, BLUE); You can make a case for each of them. I prefer using all lowercase letters just like I prefer to say Color.red instead of Color.RED when using java.awt.Color. Using lowercase also prevents having to use underscores when your enumerated values contain two or more human-readable words.

4 and 1/2) Generics
First of all, it's important that all Java programmers realize that Generics are NOTHING BUT TEMPLATES going under a new name. Templates have been around since the (mid?) eighties. In principle, templates are a good idea. They provide the flexibility of runtime type checking with the safety of compile time type checking. If used properly, templates are elegant solution that does not compromise readability or usability.

In practice templates are pure evil. In the entire history of the know universe, there has never been a programmer who has used templates correctly. The Active Template Library (ATL) and the Standard Template Library (STL) are prime examples of this. Boy, did those libraries stink like a scruffy looking nerf herder.

So the Java team took a stand, got on a soap box, and declared that template were bad -- unnecessary and prone to misuse, I believe they said -- and to be preemptively banished from Java. And they were right to do so. It saved us many years of crappy template libraries and poorly written code. I guess a new team of developers or managers made the decision to forego the original principles behind the Java language. Perhaps they forgot or never knew the reasons templates were not included in Java to begin with.

However, Java programmers should be aware of this history. Templates have a long history of misuse and bad programming practices. Thats not to say templates cant be used properly. Its just that they havent ever been used so. Hopefully, Java programmers will take more care to write better template libraries than they did when they were C++ programmers (lets face it, most of us Java programmers use to and still could program in C++). My concern is that most Java programmers will haphazardly use templates like they were in C++ making the same mistakes you see in C++ codes.

This is a big philosophical and design issue. You could write a book on the proper way to write templates actually, there probably are many C++ books for that. The important thing to remember is that changing the name of templates to generics does not change the beast. If programmers avoid the misuses of C++ templates, then Java generics will be a great asset to the language. Otherwise, were in for a lot of bad code.

5) Static imports
> I'm not too hot on this, either...
I agree. Static imports are not necessary and remove the self-documenting nature of code in the form DescriptiveClassName.descriptiveMethodName. The only justification for them is laziness, but typing has never been the bottleneck of programming. They dont contribute to readability, they subtract from it.

6) Compatibility
An issue not discussed so far is a major drawback of using the new Java 1.5 features. New features, by definition, are not backwards compatible. Before you decide to use generics, enumerations, or the enhanced for loop, make sure you are committed to abandoning the prior JDKs. Like always, many people will not migrate to the new JDK for years. It may also take a long time for these features to trickle down to the microedition of Java. (Does anyone know which if any of these features are supported in JME or when they will be?) You dont want to publish a fantastic class library that uses these features and then everybody emails you begging for a JDK 1.4.2 compliant version of the library.


Post Extras: Print Post   Remind Me!   Notify Moderator  
sud
Unregistered




Re: Taming Tiger, Part 1 [Re: Anonymous]
      #22046 - 09/22/05 06:06 AM

The modifications are very good. Especially the Boxing and UnBoxing. Not only that, the remaining things are also very nice.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Goodbye Duke! [Re: Anonymous]
      #32830 - 06/07/06 04:46 PM

man are you an idiot. Your opinion is really misinformed.

Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1 | 2 | >> (show all)



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 11059

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5