- 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
I think this is the first time I've seen a WTF hit the front page of Digg... awesome.
Admin
I really hate it when coders do have the opinion that there is such a thing like code coding that wouldn't require comments, instructions or documents. In most of the cases, it turns out only 1 or 2 people actually understands that code, and for others it is still a mystery.
Once I was as project manager in charge of a big development project working with 15 developers. When discussing the way we would document our code, one smart-ass had the opinion that he chooses his java objectnames en methods in such a way that no documentation was needed. He was really pissed off when I made him head of the testing team and also responsible for any peer-reviewing. I really hopes he learned something from it.
Admin
Until, of course, you find the complex algorithm that uses that variable and
defaultSizedIntegerVariableIndexingIntoEmployeesVectorWhichIsAVectorOfEmployeeRecordsEachOfWhichContainsPersonalInformationSuchAsFirstNameLastNameDateOfBirthAndRegisteredResidenceAsWellAsProfessionalInformationSuchAsJobTitleAndSalary_ThisVariableWasAddedByChiefSoftwareArchitectJohnDoeOnTheEveningOfWednesdayNovember12th2008RightAfterDinner
and also
defaultSizedIntegerVariableIndexingIntoEmployeesVectorWhichIsAVectorOfEmployeeRecordsEachOfWhichContainsPersonalInformationSuchAsFirstNameLastNameDateOfBirthAndRegisteredResidenceAsWellAsProfessionalInformationSuchAsJobTitleAndSalary_ThisVariableWasAddedByChiefSoftwareArchitectJohnDoeOnTheEveningOfWednesdayNovember13th2008RightBeforeDinner
(I think I had to debug that code once - on a 40 column screen.)
Admin
Try 6 character uniqueness. That was hard to live with at times. Circa 1980, iirc
Admin
I am a great fan of certain aspects of extreme programming, but this is exactly the reason, why we document in our code like this.
case InventoryIntegrationDirection.DoTheSameChangeInShop: //Do The Same Change In Shop DoChangeShop(GetChangedDataFromInventory(mLastSynchDate)); break;
case InventoryIntegrationDirection.DoTheSameChangeInInventory: //Do The Same Change In Inventory DoChangeInventory(GetChangedDataFromShop(mLastSynchDate)); break;
case InventoryIntegrationDirection.DoTheSameChangeInShopThenDoTheSameChangeInInventoryForNotChangedDataInInventory: //Do The Same Change In Shop Then Do The Same Change In Inventory For Not ChangedData In Inventory( DoChangeShop_Inventory( GetChangedDataFromInventory(mLastSynchDate), GetChangedDataFromShop(mLastSynchDate)); break;
case InventoryIntegrationDirection.DoTheSameChangeInInventoryThenDoTheSameChangeInShopForNotChangedData: //Do The Same Change In Inventory Then Do The Same Change In Shop For Not Changed Data( DoChangeInventory_Shop(GetChangedDataFromShop(mLastSynchDate), GetChangedDataFromInventory(mLastSynchDate)); break;
The nice green colour of the comments makes it clear in a second.
The Problem with Bens's boss is that he never read Kant: You should not blindly obey authority (Beck & Co) but think for yourself.
Admin
That's perhaps too long. DoTheSameChangeInShopAndInventory or DoTheSameChangeInShopAndUnchangedInventoryData would be ok, however. It's certainly much better than
This guy's code IS self documenting. It's not a wtf. He just should be more terse, when possible. Long variable names > short names with comments.
P.S. I assume that the meaning of "do the same change" is clear, given the code's context.
Admin
The real WTF is his dubious use of control flow. The naming convention itself is fine, but if he'd read Fowler's Refactoring - especially the bit about "replace conditional with polymorphism" - he'd probably have eliminated the need for such long constant names, too. Self-documenting code like this is wonderful for many reasons, one of which is that it eliminates the need for comments. The other is that it provides a nice metric for when your design stinks. Can't thinkn of a meaningful method name that isn't 50 characters long? The method's probably too busy.
Admin
That should be "another", not "the other"
Admin
Sarcasm detected, but loop counters and such are exempt from descriptive names. Anybody who can't tell a loop index has no business trying to maintain code anyway
Admin
That will make for a nice readable for loop too: for(int defaultSizedIntegerVariableIndexingIntoEmployeesVectorWhichIsAVectorOfEmployeeRecordsEachOfWhichContainsPersonalInformationSuchAsFirstNameLastNameDateOfBirthAndRegisteredResidenceAsWellAsProfessionalInformationSuchAsJobTitleAndSalary_ThisVariableWasAddedByChiefSoftwareArchitectJohnDoeOnTheEveningOfWednesdayNovember12th2008RightBeforeDinner; defaultSizedIntegerVariableIndexingIntoEmployeesVectorWhichIsAVectorOfEmployeeRecordsEachOfWhichContainsPersonalInformationSuchAsFirstNameLastNameDateOfBirthAndRegisteredResidenceAsWellAsProfessionalInformationSuchAsJobTitleAndSalary_ThisVariableWasAddedByChiefSoftwareArchitectJohnDoeOnTheEveningOfWednesdayNovember12th2008RightBeforeDinner < EmployeesVectorWhichIsAVectorOfEmployeeRecordsEachOfWhichContainsPersonalInformationSuchAsFirstNameLastNameDateOfBirthAndRegisteredResidenceAsWellAsProfessionalInformationSuchAsJobTitleAndSalary.size(); ++defaultSizedIntegerVariableIndexingIntoEmployeesVectorWhichIsAVectorOfEmployeeRecordsEachOfWhichContainsPersonalInformationSuchAsFirstNameLastNameDateOfBirthAndRegisteredResidenceAsWellAsProfessionalInformationSuchAsJobTitleAndSalary_ThisVariableWasAddedByChiefSoftwareArchitectJohnDoeOnTheEveningOfWednesdayNovember12th2008RightBeforeDinner)
Admin
What if I don't know what "++" does? Better to encapsulate that in a method called pleaseIncrementThisValueByOneBeforeIGoAnyFurther
Admin
Admin
This isn't one of them. The principle is sound, the guy's just fallen foul of some odd coding idioms.
So far, plenty of people have laughed and laughed at this naming convention, but I've seen little in the way of an actual argument about what's so wrong about it
Admin
Admin
Not a WTF. I wish there were more programs like this.
Admin
Admin
He's invented Cobol.
Admin
I would have pissed myself laughing at him or I would have taken it as some elaborate joke.
Admin
TRWTF are the readers of a website which mocks syntactically correct but still ill-used features who then go and wonder about hypothetical implications of language features that are syntactically correct but still ill-used.
Admin
Nicely cherry-picked. I have in fact said that the idiom helps one identify overly-busy pieces of code, so if you use it properly, line length does not become an issue. Also, 80 characters? In this day and age? Puh-lease!
Admin
case : wehaveonly2cases case : wehaveonly2casesandthisisthesecond case : wehaveonly2casesthisoneisforsolvingabugandshouldnotbecountedasarealcase case : crapanotherbugbutnomorethan4ok? case : ...
Admin
A lesson in the maintenance overhead of conditional logic, rather than a critique of sensible naming conventions. Nice one
Admin
Geschwindigkeitsbegrenzung?
Was ist Geschwindigkeitsbegrenzung?
Did you mean 'rev limiter'?
Admin
A 'rev limiter' would be a Drehzahlbegrenzer.
Admin
/* This is what an actual comment
Admin
soYouHaveNoIdeaWhatThisMeans?
Admin
I know the diff between speed limit and rev limit. My comment had been meant as a joke on the fact that there is no general speed limit on German motorways (Autobahn).
Admin
LineSeven: ErrorInCamelCaseExpression: FirstCharNotCapitalized!
Admin
SCNR
Admin
That's because it was a method name, not a type
Admin
Imagine the fun he would have had, back in the day, when the compiler would have ignored anything past, say, 16 chars in a function name.
DoInInventoryAndThenInBackOrders() and DoInInventoryAndThenDELETEBackOrders()
...would have both done the exact same thing!
Captcha: enim
enim...ahhh... Uhmmm. What I need after reading code like this.
Admin
Admin
Absolutely. The more local in scope, the shorter. Temps are a single char or a1, a2, b1, b2.
Larger locals try not to exceed 4 chars. The heavier a (class instance) is the longer its name, but if it is used a lot give it a Short special name: o_cust or oCu and not "CustomerObject".
static functions should be NounVerb[Predicate/Adverb/Adjective](Noun n_, Data d_): HoundReleaseHell(Hound h_, int fanglen_)
singletons : God.Is or God.Iam, not God.Instance
Member Interface 'functions' are of three types:
Commands- return SUCCESS and cause state changes, overridden Events- return void and should be overloaded to retain simplicity from callers view: o.evt(EvtBtn e_), o.evt(EvtData e_) Queries- return information and do not cause state change.
Keep code as compact as possible, but do not do multiline statements. You should be able to glance at a clump of code and sense its form. The larger the clump you can maintain this on-sight legibility with the better.
If your function takes up more than you can view, realize that you're 'copy-coding' (spelling things out simply because its easier at the moment) and not 'smart-coding' (no redundancy)
Mantra: "The code is a map of itself"
Admin
yuk
Admin
TASM had a 32 character limit on label names.
Admin
Supra shoes are so popular all over the world. Whatever you take on Supra being in the Supra Skytop Shoes market. Now Supra Strapped Shoes also very popular attention. It is nice that they actually took the time to make Supra Skate Shoes that work well. Supra shoes is a brand that has been inspired, designed and marketed by passionate individuals. We have brought to you the fullest selection of Supra footwear at cheapest price.
Admin
we do, it's called _
use it, it doesn't bite
Admin
If I ever had to maintain code written like this the first thing I would do is run it through an obfuscator so all the variables became "int1, char6, array4". I genuinely believe that would be easier to read..
Admin
Regarding the comment: „We Need To Have Support For Spaces In Variables And Function Names = True;“ –
Fun fact: In the meanwhile there are a programming language extension (Spock) based on Groovy where you can write Callables with spaces and other special char’s in their names: Java / JVM -> Groovy -> Spock
E.g.: def "This test case check that the checkout to proceed button is available and visible. So you the button can clicked."(){ }
These Callables are also usable with iterators (e.g. for a list / array of Test Cases with several inputs (e.g. several browser drivers, different URLs / Shop mandants/channels, etc.)).
Thats really freaky, but for Test Case development, parallel Test Case Execution and the output / log of Test Cases it‘s really good.
:D