Comment On Function Batman()

As a certified Überprogrammer, I get quite annoyed with inexperienced maintenance programmers looking at my code and asking questions that any coder with a clue would instinctually know. Take for example this function: [expand full text]
« PrevPage 1Next »

re: Function Batman()

2004-05-25 01:15 • by Bratek
Batman() makes perfect sense to me!

re: Function Batman()

2004-05-25 07:50 • by Phil Winstanley
Oh No! Inline SQL ! Are you sure an inexperienced maintenance programmer didn't write that?

;-)

re: Function Batman()

2004-05-25 15:53 • by Michal Chaniewski
I've seen a function named 'sh*t()' (autocensored) - and there was even a comment:

// Function does a sh*t
private void sh*t()
{
[...]
}

Sorry, no screenshot :(

re: Function Batman()

2004-05-27 15:30 • by Mark Petronis
What is a function?

re: Function Batman()

2004-05-27 15:37 • by Brock Dodgson
Good question.

re: Function Batman()

2004-06-01 18:33 • by Jim Ross
Well WTF are you doing testing a string for less than -1 when you just found out it is NULL?

I mean:
If IsNull(strFileName) Then If Len(strFileName) < -1 Then Exit Function

Have you ever tested this function with a null string? Or am I having a senior moment here or something? WTF do you expect to happen if strFileName is null?

re: Function Batman()

2004-06-02 02:56 • by Matthew
Jim,

<pedant mode>
The code is checking the Len against 1 rather than -1.
</pedant mode>

Obviously, if strFileName was ever Null (*) then the Len call will raise error 94 - Invalid Use of Null (since Null does not have a length by definition).

* Note to C programmers if they feel inclined to disagree - VB's Null is different to C's NULL. VB's Null has nothing whatsoever to do with strings (ie VB 6's Null is different to C's idea of a 'null string').

Seeya
Matthew

re: Function Batman()

2004-06-03 09:34 • by Jim Ross
My point exactly. The purpose of the test is to exit the function gracefully if a null or empty string is passed, or if an empty one is passed. As written, it will not do that, all it will do is throw an error. Great teaching tool. Not.

re: Function Batman()

2004-06-03 09:42 • by Batman Jr.
I'm batman().

re: Function Batman()

2004-07-25 01:07 • by foxyshadis
My guess is he saw that isnull is a good way to catch a bad input, and he saw that testing for len 0 (or is he expecting a negative string length?) is another good way to catch them... so why not COMBINE them for maximum usefulness and efficiency? Hey, there's an idea! =D

re: Function Batman()

2004-09-23 06:06 • by Luke
I also like the way he declares a variable for the name of a table and then doesn't bother using it, genuis!

This reminds me...

2004-10-21 23:47 • by Rick
$myhtmltemplate = <<< Myubberprogrammerwashere

(html here)

Myubberprogrammerwashere;

Hey, it's perfectly valid HEREDOC format! What's so wrong with it? :P

Re: Function Batman()

2005-05-30 07:46 • by Springstone
Of course you could also have gone with :

dim thelights

etc.

Re: Function Batman()

2005-05-31 03:55 • by Spidey
35218 in reply to 35200
It's perfectly obvious why this function is named this way. It's so you can write brilliant code like:





If TheRiddler.HasEscaped Then Call Batman()




Makes perfect sense to me.





Re: Function Batman()

2007-07-12 06:52 • by Anon Joe (unregistered)
145173 in reply to 22204
Well, actually he does use it, genius!

Re: Function Batman()

2008-07-30 09:01 • by Smash King
Oh no! I just read that
Batman = False


What will happen to Gotham now?
« PrevPage 1Next »

Add Comment