- 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
Technically, it's zip format. The only thing that associates it with Java is the extension. (I get the joke though)
Admin
Someone may have already said this but, you used the assignment operator "=" when you wanted to use the comparison operator "=="
Admin
I can think of two reasons why you might want to do something like this.
- You want to avoid if statements in the higher level code (simply write the condition as the last parameter)
- You want to flesh out your code from the top down and don't want to have to worry about the underlying methods doing something stupid because the developer that was writing them hadn't tested them out fully yet.
Course, it would be easier just to comment out the function call if you really didn't want it to run...but then again you could have some global static variable that enables all function calls simply by making it true...wouldn't have to go through line by line uncomment that pesky function call. I think it'd be really funny to have a boolean for each programmer on the project and you enable the functions that they call by setting thier corresponding boolean to true.Dim paulaCode As Boolean = True
Dim daveCode As Boolean = False
Public Sub xxx()
...
DeleteAccount("000000", paulaCode)
...
CreateAccount("000000",daveCode)
...
End Sub
Admin
That would not work.
You need getPaula().intern(), or .equals.
+ http://www.javaranch.com/campfire/StoryCups.jsp
+ http://www.javaranch.com/campfire/StoryPassBy.jsp
Admin
You have it wrong. Not using this example in all your functions is a micro optimization. Unless the function really is a bottle neck you should always add this confirmation.
Function isTrue(test, confirm)
if confirm <> isTrue(True, True)
return False
return test
end function
There, see how much better that is? Course you might want to run it through a profiler, if isTrue really is a bottle neck you can be justified for removing the check from this particular function. However that still doesn't excuse you from optimizing ALL your functions like that without using a profiler first.
Admin
Coolio.. You can also "attempt" to run the method with a value of Nothing/String.Empty as an account number. It won't tell you until you've already create the overhead of the Ado objects and it pukes on you.
Admin
On further thought, this isn't quite good enough yet - I forgot a couple of critical parts... Try:
Brillant if I do say so myself.
Admin
I bet your customers would be really happy if you were to ship this POS software after is passes all of the unit tests. And, I bet you run those tests often because they run so fast.
PHB: Why are all of our customers complaining about bugs in our latest release of PaulaRAD?
You: Don't know, it passed all of the unit tests!
PHB: Hum. Maybe we need to sell more training. Stupid users, you know.
You: Yeah!
Admin
I'm not a VB programmer, so this explanation might not make sense, but ...
Assuming that DeleteAccount() is a method in your business logic, that will be called from the GUI, this style of coding ensures that someone doesn't leave out the confirmation step. I would see it being called like so:
Admin
Admin
Admin
<font size="2">but isn't
if(showConfirmDialog())
DeleteAccount(accountNum);
</font>
Admin
No!
<FONT size=2>if(isTrue(showConfirmDialog(), True))
DeleteAccount(accountNum);</FONT>
<FONT size=2>is clearer and more efficient, not to mention performance advantagous.</FONT>
Admin
I think that's the real WTF here... since they're so keen on having layers of confirmation, why should they automatically pass the confirmation value from one layer down to the next? Clearly, since they added a CONFIRM paramater to the database command, not to use it would be a security breach. Not sure how to fix it entirely, but something like this could work as a countermeasure:
Dim bDoubleCheck as Boolean
Randomize
If CInt(Rnd * 100) <= 60 Then
' Let's give a 60% bias towards True, since they passed it as Confirm (they probably mean it)
bDoubleCheck = True
Else
'40% chance of passing False; you can't be too careful
bDoubleCheck = False
End If
Then replace the offending line with:
.CreateParamater("CONFIRM", adInteger, adParamInput, 4, CInt(bDoubleCheck))
There. NOW let's see someone try to delete a player account accidentally!
Admin
Ahhh? There's 60% chance someone will...
Admin
What gets me is not just that the person who instigated this practice was a moron, but that none of the programmers working there were willing to question the practice. "Some shops just do things differently" is not a satisfactory alternative to having a brain.
Admin
I am sorry to admit this but I worked in a place like that. Where I saw lots of odd things like this, maybe not to this degree, but still. I wish I could've done something about, but it was so entranched into their systems that it would require massive and costly code rewrite. A few people (originally inventors) thought it's the most ingenious thing ever developed, the rest thought it was plain stupid, but nothing could be done at that point to fix it. This WTF is a good example; if confirm variable is passed into every 'serious' function on many different layers then imagine how much effort has to go into removing what seems to be "harmless" extra parameter. But, I bet that original inventor of this "extra layer of confirmation" feature thinks it's the most ingenious thing, he's probably applying for a patent right now!
Admin
One might guess that none of 'foreign' developers had neither formal education in CS nor real experience at all.
Admin
I'd bet you dollars to donuts that the value of Confirm isn't passed as a known value. It's a variable or a return from another function. Probably something like this:
bool Confirm = CallSomeFunctionThatChecksIfWeShouldDeleteTheAccount()
DeleteAccount(AcctNmbr, Confirm)
It's still braindead, of course, but not quite as silly as passing a value that is known at compile time. If it were done something like this, probably no one would raise an eyebrow:
if (CallSomeFunctionThatChecksIfWeShouldDeleteTheAccount()) then
DeleteAccount(AcctNmbr)
endif
(VB isn't my language, so forgive any silly syntax errors I may have introduced.)
Admin
Maybe Confirm could be a Class that emails the developer as the implementation of the default property, to ask if they're really absolutely sure every time. Using a db lookup and xp_sendmail of course, with the sa password in the code. (password: "whydoIneedone?")
Admin
A function that is deliberately designed to work differently during testing as opposed to real use - that doesn't sound too clever either.
Admin
You give them way too much credit. The code would probably look like this:
Admin
Actually, it would be a good idea for VERY CRITICAL functions to have a second layer of confirmation to them, e.g. those that may destroy large amounts of data. A buffer overflow or some other bug (a hardware RAM glitch?) might randomly call such a function. It reminds me of a time long ago when a buggy DOS program (with nothing to do with disks) somehow called the BIOS Format Track function, wiping out a large portion of the disk. I keep wondering why the developers of the BIOS didn't implement a second level of confirmation, as that was definitely a critical function. However, doing so to non-critical functions is definitely a WTF.
Admin
Is it possible to use lazy evaluation in VB?
Maybe evaluation of the boolean will result in a dialog box being created.
That would still be very poor design, but at least it would serve some
useful purpose.
Admin
Two words: design debt.
Works a lot, the only thing is assigning monetary value to it. Somehow that always gets attention.
Admin
Saves time on post-production maintenance by directly debugging on the production server with the production database! Best design pattern ever.