Comment On But I'm Using using

There's nothing better than being called up at 4:30 in the morning to solve a production crisis. Well, aside from sleeping. Or baking. Or antique furniture restoration. But nonetheless, Alexander Shirshov was called in to help increase the SQL Server connection pool size. It would seem the backend to their retail inventory system kept generating error messages: [expand full text]
« PrevPage 1Next »

Re: But I'm Using using

2005-02-08 13:58 • by

The WTF is that if the connection hadn't been explicitely opened before the call to daHSB.Fill() then Fill would have opened and closed it automagically. Since they had opened it before the call, it stayed open.


 

Re: But I'm Using using

2005-02-08 14:37 • by Phil Scott
I'm not sure if I shared this story in the past, but I once got asked
to help improve the performance of a ticket handling application for a
church.  They were selling tickets online for their play, but
their site could only handle something silly like 20 purchases per
hour, and then their site would just hang. 



Being the quick thinker that I am, I quickly realized that 20
transactions per hour is a bit on the slow side.  Well, in the
process of working out a deal with this church, the sales guy notices a
freakin' printer plugged into their webserver.  They were printing
things on the fly when ticket purchases came in.  And when the
printer ran out of paper, the programmers simply stopped taking orders
online.



Brilliant!

Re: But I'm Using using

2005-02-08 14:47 • by fcarlier

You gotta love all the nested using statements. This would have been okay, as well:

[code language="c#"]

using(SqlConnection connHSB = DbAccess.GetConnection())
using(SqlCommand cmdHSB = DbAccess.GetStoreProcedure("CreateReceipt", new SqlParameter("@ReceiptNO", myReceiptDetail.receiptNO), new SqlParameter("@CompanyID", CompanyID.ToString())))
using(SqlDataAdapter daHSB = new SqlDataAdapter(cmdHSB))
using(dsReport dsHSB = new dsReport())
{

   // Do freaky stuff

}


 

[/code]

The efforts to create a logo for sure havent't fell of the radar :)

Re: But I'm Using using

2005-02-08 14:48 • by fcarlier
29292 in reply to 29291

Thing is that, no matter how you look at it, this message board software is indeed the biggest WTF of all.


Each using statement was supposed to go on a new line, but no, that was too much to ask :)

Re: But I'm Using using

2005-02-08 14:57 • by
Guess that programmer doesnt understand that DataSets are disconnected
objects....how sad. Isnt that one of the first things you learn when
you transition to ADO.NET.

Re: But I'm Using using

2005-02-08 16:25 • by
29297 in reply to 29294
Well hey, learning to put question marks at the end of a question is one of the first things we learn in school. I guess it's possible for everyone to forget things, isn't it?

Re: But I'm Using using

2005-02-08 16:37 • by RJ
29298 in reply to 29297
Funny one.  Perhaps code like this is the source of those "using blocks don't work" rumors?



I can't really blame the coder much for this one.  It is sloppy
not to free resources as soon as you finish with them.  But this
looks like just an easy to make mistake.

Re: But I'm Using using

2005-02-08 16:58 • by

Eh, dsReport is a type name? Yikes.


 

Re: But I'm Using using

2005-02-08 17:26 • by
J-J-J-Javascript!

Re: But I'm Using using

2005-02-08 18:52 • by
You know, reading this code, I think I finally understand what's wrong with modern programming lang -- uh, hang on.



Noun.Person(psnAbstract).AsPronoun(YOU) Verb.Infinitive.Know, Verb.Participle.Continuing("Reading") this->Noun.Abstract.Code, Noun.Person(psnConcrete).AsPronoun(psnI) Verb.Think Noun.Person(psnConcrete).AsPronoun(psnI) Adjective("Final" /* ly */).AsAdverb Verb.Infinitive("Understand")...



Uh, you get the idea.



The real WTF in today's entry is the language.  Programming languages are supposed to be less stupid than this.

Re: But I'm Using using

2005-02-08 19:04 • by
29303 in reply to 29302
What a brilliant comment, I completely agree.



I wonder what it is nowadays with most abundant (or hyped) languages being syntactically C-based (like C++, Java, and C#).



I, for one, value readability over writeability on programming
languages, and a language which uses almost all possible special
characters from the keyboard simply doesn't cut. I'm not American, but
I still believe that the DoD got a lot right in their Strawman-Steelman
progression.



(Sorry, I am drunk while writing and I now realize that this reply does
not have almost anything to do with the post I'm replying to.
Nevertheless, I believe I said something useful [:)] )

Re: But I'm Using using

2005-02-08 20:03 • by

yay, Ada rocks! AFAIK there haven't been any Ada-wtfs posted here ;)

Re: But I'm Using using

2005-02-08 20:45 • by
29308 in reply to 29305
Give me five minutes to learn Ada, and I'll set one up for you :P

C-like languages

2005-02-09 05:32 • by
C, C#, Java and C++ are all quite similar, but they and Ada are all
really just Algol dialects - as are Pascal, Perl, JavaScript, and many
more.  A case could even be made for calling Python an Algol
variant.  What, when you get down to it, is the difference between:



if ($x =~ m/[^a-zA-Z0-9_]/) {

  die "Illegal character in $x";

}



and:





if RegExp.Matches(X, '[^a-zA-Z0-9_]', []) then

begin

  raise Exception.Create('Illegal character in '+X)

end;



They're all the same, give or take a bit of syntactical sugar (like the infix =~ operator) and some search-and-replace.



A completely different language - like, say, a well customised version
of LISP or Forth, could produce a much more readable bit of code than
the parent posting.  Granted, you could improve matters in the
short term using C macros, but they come back and bite you where
extensible languages don't.  On the gripping hand, postfix and
prefix syntax are bitches.



A language with Algol's operator syntax and LISP's macros or Forth's CREATE ... DOES> would be awesome.



: Bat :

Re: C-like languages

2005-02-10 16:47 • by brandonh6k
29449 in reply to 29314
I think that's the first time I've ever seen someone use "on the gripping hand" in an actual discussion...

Re: But I'm Using using

2005-02-10 19:49 • by mxskweeb
Being a mostly VB(.NET) guy, I haven't spent a lot of time in the C
syntax derived languages, so I'm curious: do you find that using using
makes managing the disposal of resources *significantly* easier than
just disposing of them explicitly or letting them die when they go out
of scope (where appropriate)?  I'm not asking the question to
knock it; it's just that doing it that way never occurred to me and I'm
genuinely curious.

Re: But I'm Using using

2005-02-11 14:22 • by Blue
29497 in reply to 29457
I have gotten into the habit of using using statements, as there is
less chance of  forgetting to clean up after myself.  
I'm not experienced enough to know how/if cleanup happens if an
exception is thrown by the object created in the using statement, when
there are external resources (ie, db connections) involved.





Re: C-like languages

2005-02-12 08:25 • by JamesCurran
29560 in reply to 29314

:

if ($x =~ m/[^a-zA-Z0-9_]/) {
  die "Illegal character in $x";
}


Ya'know, if I had some time to play, I think I could get


if (x =~ m/"[^a-zA-Z0-9_]") {
  die ("Illegal character in "+x);
}


compling/working in C++  (I'm assuming "m" in the python script is a regex matching operator, right?)



 

Re: C-like languages

2005-02-12 11:43 • by JamesCurran
29562 in reply to 29560

OK, I had some time.... This compiles & run as expected, as either  a stright C++ program or as a .Net app.  Ask nicely & i'll post magic.h


#define DOTNET


#include "magic.h"


void Test(std::string x)
{


    if (x ==~ m/"[^a-zA-Z0-9]")
      die("Illegal character in " + x);


}


int _tmain()
{


    Test("abcDEF123");   // passes OK


    Test("#$%^&");       // Throws exception


    return 0;


}


Not exactly the syntax I was going for, but very close....

Re: C-like languages

2005-02-12 11:43 • by JamesCurran
29563 in reply to 29560

OK, I had some time.... This compiles & run as expected, as either  a stright C++ program or as a .Net app.  Ask nicely & i'll post magic.h


#define DOTNET


#include "magic.h"


void Test(std::string x)
{


    if (x ==~ m/"[^a-zA-Z0-9]")
      die("Illegal character in " + x);


}


int _tmain()
{


    Test("abcDEF123");   // passes OK


    Test("#$%^&");       // Throws exception


    return 0;


}


Not exactly the syntax I was going for, but very close....

Re: C-like languages

2005-02-12 11:51 • by
29564 in reply to 29560

Ya'know, if I had some time to play, I think I could get



if (x =~ m/"[^a-zA-Z0-9_]") {
  die ("Illegal character in "+x);
}



compling/working in C++  (I'm assuming "m" in the python script is a regex matching operator, right?)




That isn't python, judging by the =~
operator and the die keyword, I believe it's perl. In which case x is
the variable, =~ is a pattern match operator.
m/"[^a-zA-Z0-9_]" is a quoted regex pattern with multiline modifier, I think m/[^a-zA-Z0-9_]/ would be equivalent - but that isn't a promise.



Re: But I'm Using using

2005-02-13 18:15 • by bat
Cool - go looking for "polyglot programming" on
$your_search_engine_of_choice.  It's the utterly, utterly
frivolous art of writing programs that compile in two or more
languages.  One trick, for example, is starting a line with #if 0,
which in C/C++ makes the following lines invisible, but in
Perl/Python/etc is merely a comment line.  I imagine you can think
of more tricks.  Then, when you're an expert in polyglottage, try
your hand at quines...

Re: But I'm Using using

2005-02-13 18:21 • by bat
29619 in reply to 29618
Oh... and



if ($x =~ m/[^a-zA-Z0-9_]/) {

  die "Illegal character in $x";

}



... is indeed Perl -- and the other version was Delphi, a Windows-based
object-oriented Pascal.  It basically says "Fail with an error
message if even one character in the variable is illegal", where
"illegal" means anything other than a letter, a digit or an
underscore.  You might use logic like it in a "register as a new
user" script on a forum like this one (and then ignore the screams of
users who want to sign up as François or André
... but it was only an example).

« PrevPage 1Next »

Add Comment