- 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
Wow... See my previous note--I didn't even think of breaking apart the class name in this way. And it also makes sense!
Admin
Looks like a javascript coder got lost.
Admin
Nah, this isn't a WTF at all: just a very clever obfuscation program. We all know that DrugStrengthFormCountryManufacturerPharmacyCopayProductPriceFactory means absolutely nothing (go ahead, try to parse it, I dare you) so the only explanation is the code was made by a medical devices company that's very protective of its information, so it wrote a program to rename methods and variables with a string of medical-sounding gibberish.
Case closed!
Admin
Well, most of our code base are not like that. But we have at least a few deep directory/package structures with long package name and even longer class names. Combine that with a inner class with a long name (you get .class filenames of ~100 characters), and you end up very close to the 255 character limit of paths.
This structure has been the cause of a lot of problem (directory structures has had to be renamed because you cannot copy to them) and has also triggered internal bugs in xcopy.
I and other people have tried getting the developers responsible to change it, but they won't because they think they follow an guideline. Sigh...
Admin
This reminds me way back when I was learningn to program on a C64 and discovering that spaces were optional in some code. Each line in the program (numerically marked) could take up to two lines on the C64 screen, so I'd jam as much code into each line as possible. It would look something like: 100 IFX>1THENGOTO105NEXTX etc etc (apologies for my extremely rusty Basic programming skills)
Suffice to say, I was also between the ages of 10 and 14 when I was writing code like that and was also the only one that was actually reading it... huge cludges of text on my screen wasn't that big of a deal, since I could parse it out in my brain. But for anyone else to be doing something like that, even if it's a program generating it, they need to be beaten with a wet noodle. Not everyone is going to use the tool to edit the code.
has bad flashbacks to trying to manually edit FrontPage code filled with TD and TRs all over the place
-- Seejay
Admin
Admin
Years ago I had the (mis)fortune of having to debug a Fortran simulation package at NASA. The previous programmer was fond of using for his loop indices names such as :
i, ii, iiii, iiij, ij, ji....you get the picture. So in a loop, nested say, 5 deep you might see something like:
if FOO[iiij]>BAR[ijii] then FOO[ii]=2*BAR[jji]+FRED[jj]*A....etc.
Try debugging hundreds of lines of that. They were good enough for the obfuscated Fortran coding contest.
Admin
Even the VIC-20 was so much "faster" than the TI-99/4a I was stuck with. Wasn't the Apple II limited to seeing the first 2 characters in the variable names, such that BLACK and BLUE were considered to be the same?
Ahh, something else brings back memories. At my gradeschool, a C64 was used to generate the bell noises that separated the class periods over the PA system (advanced equipment there!). Whenever the power went out, somebody had to reload the program from cassette tape :D
They also had those freakish solenoid-driven clocks. Super quiet during a spelling test or whatever... Then suddenly THUNK-clank.
Admin
I can see one possible advantage of doing things this way.
Nobody in their right mind is going to borrow this code for any other application. In other words, it's completely unportable. So nobody is ever going to ask the programmer to explain how this code works.
Admin
Now I'm a fan of descriptive class and function names, but, assuming that the name is truely and accurately descriptive, a name that long is indicitive of a design problem. Looks like a perfect candidate to refactoring to an Interpreter, or buying a straightjacket and the complete DVD set of Regis and Cathy and embracing insanity with open arms.
Admin
lisp
Admin
I worked at a place that had classes just like this. They had views with a bunch of columns and their classes where just a list of the columns, and the get methods were named based on what columns actually got filled up.
Also everything was kept in two tables Information and InformationType so views were the only way to make sense of anything.
Admin
Admin
Admin
Shouldn't the singleton be named 'theCar'?
Admin
Admin
Not quite.
It works, because it's unambigious. A type name is a type name, and a variable name is a variable name. And VB allows to call sta err, I mean, shared functions from variables, anyway.
Admin
And I can hear the under-30 crowd thinking, "Why didn't you just download the code?"
Admin
Sorry, you're limited to six character names.
IIRC, Commodore Basic tokenized keywords with 2 keystroke codes. I would have said the stripped spaces too, but I may misremember.
Admin
True, yes.
Whereas Apple II did. In fact. I think Applesoft BASIC just stored numeric keys identifying the tokens, rather than their actual text (with the exception of literal strings, of course). It would always reformat things a certain way when you'd LIST, I think because it was reconstructing the text from the tokens. That was very smart of them I think.
Admin
You may complain but it is better than this sort of naming:
obj_Object obj_SomeParam i_i str_obj_ObjectParam
I had the stuff above to debug... ok... i would have LOVED those giant descriptive names, at least I would have a clue as to wtf is going on in the code!!!! So Object str_RplyObjectName = new SomeObjectActionForm();!!!!!!
Admin
Admin
I agree with this. That names is made of the columns in a table containing pharmacy data. I work with pharmacy and other medical data, and it is a mess. I get a data extract from a big Pharmacy company and it has 250 fields in it.
Trust me, if you get any code to function properly with this kind of data then you did a good job. If it also looks pretty, then you should be writing textbooks and not be in the trenches.
Admin
Yes! Thank You!
And I think this one proves that just because MS encourages something does not mean that the result is not a WTF.
Admin
And one more thing:
People who do this suffer from a misunderstanding. They think it's possible to come up with a variable name in English that perfectly describes its role. It's not possible... that's not what natural language is for. I think it's possible, and at times worthwhile, for a variable name to convey some information about its purpose. But ultimately, both "i" and "indexForNextTenForLoops" both fail at some level to describe the variable. That's why it's OK to abbreviate, truncate, and just omit a word that might seem relevant in a variable name.
Admin
I will rue the day that a widely used programming language allows spaces within identifiers. Yes, that day will be rued, but I feear code like this will convince somebody that it's a good idea.
/ Much rueing on that day.
Admin
Admin
Admin
Admin
This is the REAL WTF...
Admin
Uh... MS doesn't encourage anything this retarded. Grow some brains.
Admin
Sorry to confuse. Two separate threads. The example with all the indexes was Fortran (which had a limit of 6 char for variable name in the major dialects at that time). The Commodore BASIC comment refered back to a different post.
But I could not state categorically that there was never a version of FORTRAN for the C64.
Admin
So you can run gdb inside of emacs...big deal!
Admin
When did the Java style guidelines become obsolete? When C# won 10% of their market share?
Admin
I believe the correct expression is "Brillant!"
Admin
As someone who actually worked on the system in question, I can perhaps clarify somethings.
The code is actually C#, not Java. camelCasing is perfectly supported in C#, even if it does or does not fall within the Microsoft recommended best practices.
The code was produced within an agile shop, so any individual may touch the code in question. Long names allowed us to encode the desired functionality without the need for comments. The code was almost comment free, which means no stale comments littered over the place.
It took us about 1 iteration to break in a new developer. That means that in less than 2 weeks, we could bring on a new developer and basically have them turning out production quality code with a minimum of baby sitting (We didn't practice that much pairing. ) I have never seen a project where that was the case.
I haven't worked on the project in over 6 months, but I can
a) Identify the code as code from the project, 'cause it all looked the same, which is a good thing. In a few cases, when we wrote duplicate cards, we had instances, where there were almost zero differences between the code 2 individual wrote, since our variable naming was very well thought out.
b) Know what the code is trying to do, based admittedly with knowledge of the problem domain, but generally assisted by the name. I could walk in, sit down, and debug the code with little guidance, right now.DrugStrengthFactory doesn't work, because it isn't a drug strength factory, it is a factory to solve a very specific problem.
c) SecurityContext securityContext makes as much sense as SecurityContext contextForHandlingSecurity or SecurityContext objSecurityContext.
Admin
Admin
This happens when you use xsd.exe to create a class for a complex xml scheme. Let's say you have a <order><orderLine><detail /><orderLine></order> structure, then xsd would generate a detailOrderLineOrder class. It's pretty stupid if you ask me ;P
Admin
Dictionary completions with ctrl-n work just fine for me in vim.
-j-
Admin
Before my Pauline conversion, I was under the feeble impression that an index is not an iterator, and vice-versa.
LuckilyIHaveNowSeenTheErrorOfMyWaysCommaAndRepented. (Catching, isn't it? I really think it needs proper grammar and punctuation added to the standard.) But, in my previous life as a heretic, I would have made the baseless claim (well, pointless, anyway) that naming an iterator "i" is lazy but sufficient ("it" or "iter," anyone?) whereas naming an iterator anything like "index" is just plain fucking thick and misleading. Unless it's accompanied by a stale comment, reeking of fish, of course.
Frankly, this whole thread has put me off buying my drugs from Big Pharma. From now on, I'm going to stick to the neighbourhood crack dealer.
Admin
LISP, Tcl, Forth, SQL (with double quotes)...
Tcl even allows the empty string as an identifier, e.g.
"" $()
calls the empty-string procedure with the value of the empty-string key in the empty-string associative array as a parameter. The variable and procedure are in the empty-string namespace, but most languages have that (and call it "global").
Replacing each empty string in a distinct identifier namespace with a non-empty identifier, the above code is equivalent to:
Since the 3 empty identifier strings in the Tcl example are in different namespaces, the equivalent examples use 3 different non-empty identifiers (foo, bar, and quux).
In Perl I suspect you could directly manipulate *_ and create hyphens in identifiers in that language too (and of course '-' itself is the name of a system variable) but I'm not sure how you'd ever access such an identifier.
Admin
Modern vi implementations have autocompletion too...
Admin
Of the two I prefer 'aCar' (although for a singleton I'd use 'theCar') since (assuming rigorous following of coding standards) a global search for "Car" will find all the class references and the instances too (along with a pile of false positives of course).
The trouble with 'car' is that it's spelled differently from 'Car'.
Admin
(Assuming you're not joking...)
"Everyone knows" that comments diverge from the code they document. But since this is due to the code changing and the comments/documentation not getting updated, surely this means that the name of a very specifically named type will no longer quite match what the type is for.
I would argue that is the greater of two sucky situations because we give more weight to the type names.
Admin
Everybody did that, I think.
The MS basic on the Tandy Color Computers (all of the half-dozen or so ROM versions) used up-to-2-character variable names. I can't remember if longer names were allowed, or if it was an error of some kind. The ROM would parse tokens and store them in memory as single characters, leading to things like a limit of 128 tokens in the language, and mandatory spaces around some tokens in program listings. Also there was an "advanced line editor" (yep, Microsoft wrote those ROMs all right ;-) that could allow you to give variables the same names as reserved words if you edited the line in the right order (type these three characters, delete one in between, press ENTER). If you attempted to simply enter the line from e.g. a printed copy of the code, you'd get a syntax error.
The Sinclair ZX81 took this to a whole new level, though: it used tokens for keyboard entry (you would press something like "K" for the "PRINT " keyword) and also for the display. There was no lexical parser since it was impossible to enter invalid tokens through the keyboard. If you wanted to enter a function call there was a shift-like key for that. IIRC you only had single-letter variable names, but with 1K of RAM that wasn't the biggest limitation to worry about.
These systems drove your TV set with the CPU literally clocking out pixels in real time (this was many years before cheap video controller chips were available, and yes display refresh did take up 90% or so of the available CPU time, with user programs executing only during the vertical blanking interval). With a grant total of 1K of RAM in the system shared between video, programs, and data, you can't really waste a lot of space copying individual letters into a frame buffer, so the display memory area would contain things like newline characters that actually behaved like newline characters (and saved up to 31 bytes of memory if the entire line was blank). If you're really low on memory, the system reduces the number of lines visible on the screen.
If you stored the character code for "PRINT " (yes, including the trailing space) in the display memory area, the word "PRINT " would appear at that point on the screen (possibly doing weird things to the rest of the line if it went off the right edge). If you looked really closely you'd see that the positions of other characters on the display would shift slightly depending on the mix of keywords and non-keywords displayed, because of small changes in timing through the software display loop (although you'd never be able to see this on a late 1970's/early 1980's TV set, because they're even less precise).
Admin
I do miss the ability to blame breaking the nightly build on an inadvertent finger fumble whilst changing modes, though.
Now we've got autocompletion, my life is complete! I can go back to vi, and all those idiots who use Notepad will no longer have a reason to sneer at me!
Admin
heh... try using wscompile.. http://dione.zcu.cz/studium/doc/lang/java/docs/webservices-1.1/tutorial/doc/JAXRPC6.html
Admin
ahh ... all this thread reminded me of that database4 some team did for a distributed application concept. One of the tables had fields named like
Air Conditioning Unit and Heater Power Windows 5 gear manual transmission system Anti_Lock Breaking System
you get the idea. And no, they weren't a boolean/binary type. They were nvarchar(255).
Oh, and all this talk about C64's and basic brought up old memories... one-lettered vars, LOAD "program",8,1 ... aaah ... those days...
Admin
Do you mean that the Java conventions are obsolete? he has followed the [url:http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html#367]current version[/url] of the conventions as laid down by Sun.
Admin