- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
There was no joke, which is what makes it funny. :)
Admin
Also, I can kill you with my brain.
Admin
Admin
Examples of languages which handle this perfectly: OCaml and Haskell. There enumerations are just a trivial case of algebraic data types.
Admin
Admin
Yes - he forgot 'File not found'
Admin
Admin
boog, at what point does "not putting something to use that you don't need" become laughably absurd to you in Java? Abstract classes? Static methods? Methods period?
Your premise, that someone who fails to understand how to "put something to use" that s/he does not understand is not necessarily a bad programmer, is completely nonsensical. By that logic I could be a decent OO programmer producing a program with one class with 20 static methods simply because it is not "useful" to me to understand any of the following concepts:
Class instantiation Member variables Non-static methods
etc.
Do you see why what you're saying is ridiculous?
Admin
By need, I don't mean the literal sense you've suggested. And what's useful/powerful to one person might be overly-complex/burdensome-to-maintain to another. That doesn't make either person a bad programmer.
Admin
Admin
Perhaps there are contexts where the distinction matters, but I'm hard pressed to think of them. I certainly don't see how it matters when discussing text stored in a computer. Well, unless you are using an encoding which represents uppercase and capital letters differently, but I doubt such an encoding exists.
Admin
Admin
haha, alright man.
Admin
Admin
Wow, reading comprehension fail!
The fact that I don't use every nook and cranny of my development platform doesn't make me a bad programmer. In fact, it makes me an efficient programmer. I'm going to use the correct tools for the correct situations.
Does the problem call for an instance of an object? No? Ok then, I can create a static class with static methods. I can even add some caching and thread safety to make it hella fast...
Do I need object inheritance? Yes? Abstract, and away we go!
Do I need loose coupling? Yes? Here we are, interfaces...
Your argument is nonsensical and completely off the mark, but you keep supplying and proving your own arguments... It makes you more right, right?
Admin
I said the guys ripping on all the whizbang-bells-and-whistles that come with Java's Enum are entitled to their opinions, and that not having any business or design need for Java's Enum themselves does not make them bad programmers. What about this has to do with programming skill?
Admin
Yes, just yesterday I mailed my tax return to Harrisburg, the upper case of Pennsylvania.
Admin
I tried to open a business there but couldn't get enough venture upper case raised.
Admin
Um, yes. Except, as you explicitly stated, you have a clear understanding of when to use language-appropriate tools. That was not the context of the original statement, which you conveniently ignored.
If we go to the context of the original post, the hypothetical developer in question is not convinced of the utility of a particular language tool. Perhaps he is justifiably skeptical of the benefits or uses that the tool brings, when weighed alongside any negatives, or perhaps not.
boog then replied that one who does not see as tool as useful means that one has no use for the tool himself (or perhaps he meant something different, I'm not sure). He then asked, "Are you really suggesting he's not a good programmer because he doesn't know how to make use of features he doesn't need?"
My stance is that yes, one can be an absolutely terrible programmer by not understanding how to make use of (==not understanding how to use? Apparently not) features that he "doesn't need". Nobody really needs to use objects, interfaces, abstract classes, polymorphism, threads, or methods besides main() to be a java developer. Indeed, a poor developer could very likely convince himself that these things aren't needed at all, and as a result, not understand how to make use of them.
Anyway, it's now obvious to me that I read way too much into boog's statement. My bad.
Admin
I'm sure there's some reasonable explanation for why 'H' and 'O' are capitalized...
Admin
Ha, I was going to say "except extension methods in C#" (we think alike, it's scary)... I do like them, but not too crazy about them. They're just syntactic sugar, and aren't really supported by intellisense (try to type .ToIntPtr if you don't have the right using statement where the extension is defined), also because a while back a developer I very highly respect convinced me that it's not "pure", but that's neither here nor there...
In any case, extension methods are different because it's not like you're subtyping Int32, right? And that's what bothers me because you're giving different meaning to something that is a single unit of something. It also breaks polymorphism (which obviously doesn't work for value types anyway) because if MyEnumType.First has a .ToFoo(), but MyEnumType.Second has a .ToBar(), then you're doing something wrong IMO (imagine the code necessary to handle that). Of course all of this is useless if my understanding of java enums is completely off base...
Admin
"Actually, Java has had proper enums for over 6 years"
Ooooh, 6 years, fancy that.
Yet I was using them in Pascal in the 1980s.
Admin
The ability to troll people I guess.
Admin
Although this would be difficult to implement using Windows, an enumeration of strings could conceptually be done in an embedded environment using a vector table.
First, you'd need to define a location in memory for the vector table. Let's call it VTBL_ADDR.
Next, define your enumeration:
Setup the vector table at the predefined address. Different compilers may use pragma or linker settings. The vector table would look something like this:
The strings need to be declared separately because we need to know where each is located in memory for this to work.
Finally, the application's init code needs to wire the vector table to the strings:
Viola! You now have a string enumeration. Essentially, an enumeration of pointers boils down to an enumeration of integers. I did something similar to this for a project about a year ago, so I know it can be done. However, this code I wrote off the top of my head and is untested; it may (probably) needs some tweaking.
Admin
Okay, lol, MAX_ENUMS would need to be defined separately.
Admin
Context matters. Morons.
Admin
Admin
Admin
That might make some sense if (1) it was commented as such and (2) you only ever have one legacy program per data field (or they all use the same values). Personally, I would create functions like TranslateFooToLegacyBar(), where Foo is the name of the data field and Bar is the name of the legacy program.
Admin
besides if you live dangerously and unlock your caps you will notice that the letters in your post are not shaped anything like the drawings on your key caps. see? they hacked your font!
Admin
Admin
Good job, boog.
Admin
A very good point. Only people who have real programming jobs getting computers to do something interesting and/or important get to discover the delightful convenience and elegance of a fully-fledged enum implementation. If, as you say, your job doesn't put that level of intellectual demands upon you, you can happily get away without bothering to get to grips with enums at all.
Admin
Um ... Dutch caps? So caps lock is a bit like a chastity belt, yeah?
Admin
... or, to it's absurd yet logical conclusion, software development as a whole too...
Admin
"Viola". OFFS, someone else on the big fiddle.
Admin
Admin
+5001 FUCKING BIG WIN.
Admin
The enum type also comes with a few other handy features like a name method which returns the enum's name as a string (we actually store enum names in the database rather than worrying about having and syncing a separate enum names table), being iterable (iterate over the values of the enum).
Of course the bottom line in deciding if it's worth having all of this extra functionality is the question: what do I want/need to do with this enum? Is there some functionality that would be worth putting on the enum itself?
One example I can think of is with statuses where some statuses are errors (application died, database error, application error, data error), some are success (success with new data, success but no data). You could mark in the enum which values are errors and which are success. Then you don't have to have a separate function which remembers which ones are which because it is right there on the enum value.
Admin
Admin
Admin
Admin
I think the last two posters don't understand the difference between capital and capitol.
CAPTCHA: eros - as in, those posters commited an eros.
Admin
Code needs to be refactored if that's your best example. An enum in this case should only indicate SUCCESS or FAILURE and whatever object that holds the contents of that enum should describe the type (ApplicationResponse, DatabaseResponse, SoapResponse, EnterpriseyResponse)
Admin
Note that I have toured the Capitol while visiting the Capital.
Admin
None of the previous posts mentioned need "capitol".
Admin
Sorry 'dude, but capitol is used solely to refer to "the building in which a legislative assembly meets".
Admin
Admin
Thanks for explaining that more clearly, but I have got to ask, what is the difference between an enum and a class other than the type modifier (class vs enum)?
Admin
and here I was thinking "Capitol" is some building in America.