| « Prev | Page 1 | Page 2 | Page 3 | Next » |
|
So, please fill me in: In what regard are ENUMs in any other language more useful than Java's?
|
|
The WTF was how he used them, not the language construct.
But let the Java bashing begin ... |
|
Argh, it makes you want to get a gun and shoot people.
|
Not actually the point... |
|
What is "alma matter"? I think the WTF-U certainly does matter, and that it is the alma mater for the Paula's in this world.
|
|
Yeah we've never ended up in quite that bad a trainwreck, but we've definitely run into things that seemed like enums on initial design, but ended up in the database before our clients were done requesting features.
BTW, as someone who's been away from Java since 1.3 or so, what's the point of the extra stuff in a Java enum? How are these better than enum Foo { bar=1, baz=2 ... } ? Are they like basically static structs? |
|
This reminds me of my freshmen year in college, where any sorting I had to write was always bubble sort because it was the simplest to write and I couldn't be damned to remember the other types or look them up.
I'm now a senior, and mainly use the built in sorts for languages I code in. However, it's my initial answer to just about anything CS-related, even if it's not sort related. "So, how do you think Google stores your preferences?" "BUBBLE SORT!" |
|
Mmmm, I like the security at WTFU. Intro to CS class at Virginia Tech had online quizzes that were graded by javascript, then the final score on the assignment was posted to a perl script that recorded it. Shockingly I got 100% on all of them....
|
You're new here aren't you? Alex never proof-reads his post, especially since he's got a couple thousand of us to do it for him. Besides, I don't care what you say, I will refuse to admin that I'm wrong as well. |
|
This is probably obvious but I want to say it. Tool Blame is such a WTF but we need to remember that sometimes, Tool Blame is valid. As someone who has delved into the inner workings of parts of the .NET framework, I can safely say... WTF???????
But this definitely is an example of a WTF Tool Blame. |
|
You know you've been at a computer too long when you misspell "admit" with "admin," simply because that's what your fingers are used to typing.
CAPTCHA: stinky. but i just got out of the shower. |
I figured :-) ENUMs are pretty much static in all languages I know of. Thus, if requirements are static, or the only people having to fumble with them are the server-side developers, ENUMs might be fine. Requirements change all the time, naturally, and if users are supposed to be able to change run-time properties, and that fact was known from the start, then, of course, some more dynamic approach of any kind would be a good start, right from the start. |
In general, adding extra stuff to an enum is a backward approach. It's strong coupling. What Enric should have been doing was using enums the way all languages have used them for years, as simple closed value sets. Any other information one wishes to associate with enums can be, and should have been, associated with the enum values using a Map. Java even has a special high-performance class for that, EnumMap. I hope it's true that Enric eventually realized his mistake, and came to understand the drawbacks of tightly binding so much of his application to his data objects. |
Re: Tool Blame
2007-03-06 15:05
•
by
Pecos Bill
(unregistered)
|
PRICELESS! No doubt you earned them due to your knowledge. It would seem to me that enums would be handy for Error code mappings but I'm not a Java geek. So, can one actually be fired from a Work Study for incompetence? I'm guessing no. |
|
Blaming the tool is only forgivable if it's PHP, but Java? I don't use it but it got one of the most consistent APIs out there (excluding 3rd party frameworks).
|
Reminds me of a Graduate-level course in s/w engineering on testing, verification & validation that I took. Online class. A dozen reading assignments, with a quiz afterwards. The questions from the quizzes were taken word from the reading. To pass the quizzes, open another browser window, pull up reading assignment, Ctrl-F [unique set of words]. The questions were in the same order that content was presented. Oh, and the final was entirely questions from the quizzes. Surprisingly I did well. :) |
|
I blame a lot of bad code on the tools I work with.
|
Hmmmm.... I blame a lot of bad tools on the code I work with. I inherited a boatload of spaghetti that looks like it spent 2 years in a blender on puree. The tools I am stuck using are required because there are no other tools that work within the context of our architecture *sighs* I tend to copy the code into Eclipse (not that I like Eclipse, mind you, there's nothing wrong with it; personally I just don't care for it), work with it, then copy it back. It's a pain, but a lot less painful than the older tools. This place needs to upgrade to the 1980's toolsets... :bangs head on desk: [Edit] make that 1990's toolsets |
Ok, I was talking about the tool sitting over there. |
|
It will be curious to read the comments on this one; very few people here seem to recognize that they are responsible for the code they write, not the tools they are using. I've never seen any "programming" community place so much blame on technology when defending bad code or claiming that it is not possible to write good code in a particular language.
Will people understand this post or start bashing java? Will they start comparing enums in java with enums in other languages and debating which language could best implement the code this person was trying to write? Will they comment on how enums are handled in C versus VB6 and then complain how VB6 forces them to use enums incorrectly? Will they come up with new and inventive ways to dynamically alter enums at runtime?? I can't wait to find out! One things is for sure: when it comes to "Tool Blame", we have many experts here .... |
That's the college that all physicists went to obviously. It doesn't take an Einstein to know that. By the way, if you have never heard of Einstein then you can find his website at www.emc.com. Weird though, the slogan is "where information lives" but this Einstein dude is dead. |
|
with this! http://tinyurl.com/33q94b
|
I am not a java hater, but consistent API? Some examples from http://mindprod.com/jgloss/gotchas.html // ways to set text in a component TextField.setText(); Label.setText(); Button.setLabel(); AbstractButton.setText(); Frame.setTitle(); // ways to change an element setCharAt(int index, char c ); Vector.setElementAt( Object o, intindex ); List.set( int index, Object o ); // ways to get length lenOfArray = myArray.length; lenOfString = myString.length(); myList.size(); |
Consistent, but bloated beyond excess. |
|
enums are stupid. magic numbers and #DEF is where its at.
|
Re: Tool Blame
2007-03-06 15:59
•
by
Scooter Libby
(unregistered)
|
Brain's younger sister. She's engaged to Pinky. |
|
Tool Blame? more like Tool misunderstanding. These Java enums sound somewhat interesting (better than C++ in some ways but not enough to give up my non virtual machine based language).
This is like the guy who writes his own obscure language program to work with a Database format he comes up with because he doesn't know SQL, and then complains when he has to convert the whole thing into SQL. |
|
I think we have a new definition for "WTF": "Was Tool's Fault"
|
Enums in Java are pretty much full fledged classes. Each enum constant can call any constructor you provide, and the enum class you create can have its own static and instance methods. Each enum constant can even be its own inner class; e.g., define an abstract method in the enum class and implement it in the constant. Off the top of my head (there may be typos):
|
|
I forgot to add to my enum post above that what's nice about this is now you can keep everything about the enum constant in one place: internal ids, display names, descriptions, database representation, even how it is used, can all be stored in the enum. Enums can even implement interfaces, so multiple types of enums can have methods in common. Of course, it can be taken too far, but overall they're an excellent addition to Java, and can really help in maintainability
|
Java's enums allow an easy and standardized way of converting from Strings to enums. In C++, some framework must be invented for converting external data into enums. For example: enum Colors { RED, GREEN, YELLOW }; Colors c = Colors.valueOf("GREEN"); if( c == null ) { System.out.println("Not a valid color"); else dye(c); |
|
The REAL WTF is Java trying to redefine what an enum is.
|
Only 100? I got 150 |
Re: Tool Blame
2007-03-06 16:19
•
by
anony-moose
(unregistered)
|
I got FILE_NOT_FOUND :( |
Re: Tool Blame
2007-03-06 16:32
•
by
trianglman
(unregistered)
|
Blaming the tool is rarely forgivable. It is much more often a case of using the wrong tool. I wouldn't use C to write a quick text parsing script no more than I would use PHP to write a desktop app. But there are very few languages that don't have their place (personally, PICK BASIC is one of those few, although I am sure it might have been useful 15+ years ago.) |
|
How about a new WTF policy: auto-delete of any post containing the text "CAPTCHA:".
CAPTCHA: paint. We should paint this policy in big red letters. |
Re: Tool Blame
2007-03-06 16:35
•
by
diaphanein
(unregistered)
|
|
So the saying does, when you hold in your hand a hammer, everything looks like a nail.
|
|
The REAL WTF is that some people use VB!
captcha: stinky, the one he smelt it - dealt it |
I don't know about today, but I believe 15 years ago, the New York City Public Library computers used Pick BASIC. :-) <NITPICK> Pick is not an acronym and should not be all caps. Dick Pick would be insulted.</NITPICK> |
|
Paul,
Thanks for the response. I'm not sure if I like this type of enum or not, but it's definitely an interesting idea. One thing that leaps to mind is that if there weren't too much code associated with it, you could adapt things like a strategy pattern to run everything directly inside an enum. |
It's where the soul meets the road. -Harrow. |
|
A dick pick nit pick?
|
Given it's just an intro class, I'd say anyone with the wherewithal to hack the grading system deserves 100%. |
I was afraid I was too subtle. Thanks. |
|
I fully sympathize with Enric. I don't know how many times I've run up against the limits of a tool. For example, I've yet to find a language that allows you to programmatically change the value of a constant. What's up with that?
Compilers --that's another thing. Why can't they make one that actually works? Every time I use one it does nothing but spit out errors. That reminds me: when is this new forum software going to be updated to let users see a registered commenter's bio? --Rank |
Re: Tool Blame
2007-03-06 17:31
•
by
mysterious.e
(unregistered)
|
|
Just think, this poor guy used enums when he could have used agile soa.
Who needs to use a database, or research technology best practices, when you can use agile soa. Go figure. ;) |
I know a now still working system based on GW basic and remote PC, that does the counting of all produce of a farmers cooperation. For as far as i know, it's still in operation. |
Holy reading comprehension, Batman. Did we read the same article? |
|
Old school Fortran. You could pass a constant as a parameter to a subroutine, and then change it within the subroutine. This feature, combined with punched card input, made debugging a character-building experience.
Brings back fond memories... |
| « Prev | Page 1 | Page 2 | Page 3 | Next » |