Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Flamadiddle
May 9, 2004

Just found a bug in our code that sends e-mails(MSSQL):

code:

	FETCH NEXT FROM Cursor 
		INTO 	@PersonID,@PersonName

		set @SendTo = @PersonID + '@domain.com'

		WHILE @@FETCH_STATUS = 0
		BEGIN
                    --SEND EMAIL MESSAGE TO @SendTo HERE--

			FETCH NEXT FROM Cursor 
			INTO 	
			@PersonID,@PersonName
		END

Oh dear.... We'd been sending a tonne of e-mails to the first recipient on our list because the e-mail construct was outside the loop. The weird thing is, no-one complained (even people who received 100 identical e-mails at a time), so we had no idea.

Adbot
ADBOT LOVES YOU

MagneticWombats
Aug 19, 2004
JUMP!

Mustach posted:

0.
code:
// Node that can hold anything
class ListNode{
  void * value;
public:
  // ...
  ~ListNode(){
    delete value;
  }
};

Why would someone attempt that?

Zombywuf
Mar 29, 2008

MagneticWombats posted:

Why would someone attempt that?
Templates are bad mmmkay?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

MagneticWombats posted:

Why would someone attempt that?

It resembles nothing so much as a failed attempt at a CS assignment, if it's from Industry(tm) I would assume it's from someone that thinks STL lists are Too Slow or sth else real dumb, as it's using C style genericity (although I thought void* wasn't a universal implicit cast in C++?) without knowing how free()/delete works

Painless
Jan 9, 2005

Turn ons: frogs, small mammals, piles of compost
Turn offs: large birds, pitchforks
See you at the beach!

Otto Skorzeny posted:

STL lists are Too Slow

Ugggh these people are everywhere and it's never an argument against the design, it's always "I used dinkumware STL 0.1 on Visual C++ 6.0 in a trivial benchmark with a new/delete allocator and it was slower than java! So what the gently caress"

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Painless posted:

Ugggh these people are everywhere and it's never an argument against the design, it's always "I used dinkumware STL 0.1 on Visual C++ 6.0 in a trivial benchmark with a new/delete allocator and it was slower than java! So what the gently caress"

The design is awful too, though.

Zombywuf
Mar 29, 2008

Avenging Dentist posted:

The design is awful too, though.
Linked lists are just slow.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
I've realized that my posting has gotten crankier lately and it has to do with finding things like this:
code:
//    All objects of this class must be created with
//    the new operator.  Buffer objects of static
//    duration must never be declared.
Specifically, placement new. Here's an example of one of the many overloaded news:
code:
void* Buffer::operator new ( size_t /* dummy_size */, const string & str, int base, char delim )
{
    Buffer* new_buf = new( str.c_str(), base )Buffer();
    return( new_buf) ;
}
Also, new Buffer() == NULL.

RussianManiac
Dec 27, 2005

by Ozmaugh

Mustach posted:

I've realized that my posting has gotten crankier lately and it has to do with finding things like this:
code:
//    All objects of this class must be created with
//    the new operator.  Buffer objects of static
//    duration must never be declared.
Specifically, placement new. Here's an example of one of the many overloaded news:
code:
void* Buffer::operator new ( size_t /* dummy_size */, const string & str, int base, char delim )
{
    Buffer* new_buf = new( str.c_str(), base )Buffer();
    return( new_buf) ;
}
Also, new Buffer() == NULL.

What the gently caress is this poo poo? Why not just do char * buff = malloc( num_bytes);?

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Because ten years ago someone decided that we needed a "Buffer" "class" that offers no advantages over even plain C-style strings and now it's used everywhere by pretty much everyone.

Zombywuf
Mar 29, 2008

Mustach posted:

I've realized that my posting has gotten crankier lately and it has to do with finding things like this:
code:
//    All objects of this class must be created with
//    the new operator.  Buffer objects of static
//    duration must never be declared.
Specifically, placement new. Here's an example of one of the many overloaded news:
code:
void* Buffer::operator new ( size_t /* dummy_size */, const string & str, int base, char delim )
{
    Buffer* new_buf = new( str.c_str(), base )Buffer();
    return( new_buf) ;
}
Also, new Buffer() == NULL.

That is the worst C++ thing I have ever seen.

Lexical Unit
Sep 16, 2003

C++:
code:
int sign = (1, 0, -1);
float f = /* ... */;
float f_neg = (f == fabs (f)) ? 1.0 : -1.0;
float some_calc = fabs (f * /* ... */);
some_calc *= f_neg * sign;
Production code. All I've done is change the names and remove the boring parts.

king_kilr
May 25, 2007

Lexical Unit posted:

C++:
code:
int sign = (1, 0, -1);
float f = /* ... */;
float f_neg = (f == fabs (f)) ? 1.0 : -1.0;
float some_calc = fabs (f * /* ... */);
some_calc *= f_neg * sign;
Production code. All I've done is change the names and remove the boring parts.

I'm brought comfort by the knowledge that the optimizer is probably sorting that out.

Zombywuf
Mar 29, 2008

code:
       def get_from_cache(self, key):
        	"""                                                                                                                                                                     
                Abstract - to override                                                                                                                                                  
                """
		return None
So right, and yet so wrong. :psyduck:

BigRedDot
Mar 6, 2008

Lexical Unit posted:

code:
int sign = (1, 0, -1);
float f = /* ... */;
float f_neg = (f == fabs (f)) ? 1.0 : -1.0;
float some_calc = fabs (f * /* ... */);
I suppose I should take comfort knowing that this individual no longer works here, OTOH they left because they got into CS grad school. :aaaaa: I wonder what clever thing they thought they were accomplishing with "int sign = (1, 0, -1);"

BigRedDot fucked around with this message at 15:49 on Sep 29, 2009

king_kilr
May 25, 2007

Zombywuf posted:

code:
       def get_from_cache(self, key):
        	"""                                                                                                                                                                     
                Abstract - to override                                                                                                                                                  
                """
		return None
So right, and yet so wrong. :psyduck:

Trailing whitespace, mixed spaces and tabs, and 8 space indents are never right :colbert:

UraniumAnchor
May 21, 2006

Not a walrus.
Not specifically a coding horror but heard from a CS student in the hallway:

quote:

Why do we need hardware floating point? Computers are fast enough to do arbitrary precision anyway!

:eng99:

RussianManiac
Dec 27, 2005

by Ozmaugh

UraniumAnchor posted:

Not specifically a coding horror but heard from a CS student in the hallway:


:eng99:

Were they under-grad or grad? Also what year as under-grad?

UraniumAnchor
May 21, 2006

Not a walrus.

RussianManiac posted:

Were they under-grad or grad? Also what year as under-grad?

Sophomore.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Half the time you hear dumber poo poo from grad students tbqh

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

UraniumAnchor posted:

Not specifically a coding horror but heard from a CS student in the hallway:


:eng99:

To try and rationalize that mentality, the difference is probably imperceivable for the little crappy things that they do. They haven't tried to do operations with huge datasets to know the difference.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
^^^ Basically the kid's never thought about how an arbitrary-precision math library works, he ought to know about asymptotic time bounds and such by sophomore year

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Arbitrary-precision math? More like symbolic math, helllll yeah. :hellyeah:

HFX
Nov 29, 2004

UraniumAnchor posted:

Not specifically a coding horror but heard from a CS student in the hallway:


:eng99:

Well to be honest, the more I've programmed, the more I like languages which tend to have the most powerful representation as the default (Lisp, Scheme, Haskell) with the ability to constrain to smaller faster machine dependent types when needed.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
What does what you said have anything to with what you quoted?

Athas
Aug 6, 2007

fuck that joker

HFX posted:

Well to be honest, the more I've programmed, the more I like languages which tend to have the most powerful representation as the default (Lisp, Scheme, Haskell) with the ability to constrain to smaller faster machine dependent types when needed.

But said languages are useful because you can drop down to machine-level operations when necessary.

UserNotFound
May 7, 2006
???
I have an SQL statement that is AT LEAST twice as long as the 5000 character limit per post, and there's an error in it somewhere:

....
CITIZENSHIP.COUNTRY_ID = COUNTRY.ID and COUNTRY.REGION_ID = REGION.ID) ON (CITID = APPLICANT.CITIZENSHIP_ID) LEFT JOIN (select APPLICANT_STATUS.APPLICANT_ID as SAPP_ID, STATUS.NAME as SNAME from STATUS, APPLICANT_STATUS where APPLICANT_STATUS.STATUS_ID = STATUS.ID and APPLICANT_STATUS.GARGROUP_ID = 44) ON SAPP_ID = APPLICANT.ID LEFT JOIN (select APPLICANT_SUPPORT.APPLICANT_ID as SUPAPP_ID, SUPPORT.NAME as SUPNAME from SUPPORT, APPLICANT_SUPPORT where APPLICANT_SUPPORT.SUPPORT_ID = SUPPORT.ID and APPLICANT_SUPPORT.GARGROUP_ID = 44) ON SUPAPP_ID = APPLICANT.ID WHERE "MAJOR1" = '5' AND "ENROLL" = 'NonDeg' AND "RNAME" = 'China'SELECT DISTINCT APPLICANT.ID as APPID FROM "APPLICANT" JOIN (select PROGRAM.TERM_ID as PTID, PROGRAM.YEAR_ID as PYID, PROGRAM.APPLICANT_ID as P_APP_ID, YEAR.NAME as YNAME, TERM.NAME as TNAME from PROGRAM join YEAR on (PROGRAM.YEAR_ID = YEAR.ID) join TERM on (PROGRAM.TERM_ID = TERM.ID) where YEAR.NAME = '2010' and TERM.NAME = 'Spring') ON P_APP_ID = APPLICANT.ID LEFT JOIN (select PROGRAM.APPLICANT_ID as PROGRAM_APP_ID, PROGRAM.MAJOR_ID as MAJOR1, ENROLLOBJ.ABBRV as ENROLL from PROGRAM, ENROLLOBJ where PROGRAM.ENROLLOBJ_ID = ENROLLOBJ.ID) ON PROGRAM_APP_ID = APPLICANT.ID JOIN (select APPLICANT_GARGROUP.APPLICANT_ID as APP_GARGROUP, APPLICANT_GARGROUP.GARGROUP_ID as GAR_GROUP_ID from APPLICANT_GARGROUP where APPLICANT_GARGROUP.GARGROUP_ID = 44) ON APP_GARGROUP = APPLICANT.ID LEFT JOIN (select GENDER.NAME as GENDERNAME, GENDER.ID as GENDERID from GENDER) ON (GENDERID = APPLICANT.GENDER_ID) LEFT JOIN (select ETHNICITY.NAME as ETHNICITYNAME, ETHNICITY.ID as ETHNICITYID from ETHNICITY) ON (ETHNICITYID = APPLICANT.ETHNICITY_ID) LEFT JOIN (select COUNTRY.NAME as COUNTRYNAME, CITIZENSHIP.ID as CITID, REGION.NAME as RNAME from COUNTRY, REGION, CITIZENSHIP where CITIZENSHIP.COUNTRY_ID = COUNTRY.ID and COUNTRY.REGION_ID = REGION.ID) ON (CITID = APPLICANT.CITIZENSHIP_ID) LEFT JOIN (select APPLICANT_STATUS.APPLICANT_ID as SAPP_ID, STATUS.NAME as SNAME from STATUS, APPLICANT_STATUS where APPLICANT_STATUS.STATUS_ID = STATUS.ID and APPLICANT_STATUS.GARGROUP_ID = 44) ON SAPP_ID = APPLICANT.ID LEFT JOIN (select APPLICANT_SUPPORT.APPLICANT_ID as SUPAPP_ID, SUPPORT.NAME as SUPNAME from SUPPORT, APPLICANT_SUPPORT where APPLICANT_SUPPORT.SUPPORT_ID = SUPPORT.ID and APPLICANT_SUPPORT.GARGROUP_ID = 44) ON SUPAPP_ID = APPLICANT.ID WHERE "MAJOR1" = '5' AND "ENROLL" = 'NonDeg' AND "RNAME" = 'India'SELECT DISTINCT APPLICANT.ID as APPID FROM "APPLICANT" JOIN (select PROGRAM.TERM_ID as PTID, PROGRAM.YEAR_ID as PYID, PROGRAM.APPLICANT_ID as P_APP_ID, YEAR.NAME as YNAME, TERM.NAME as TNAME from PROGRAM join YEAR on (PROGRAM.YEAR_ID = YEAR.ID) join TERM on (PROGRAM.TERM_ID = TERM.ID) where YEAR.NAME = '2010' and TERM.NAME = 'Spring') ON P_APP_ID = APPLICANT.ID LEFT JOIN (select PROGRAM.APPLICANT_ID as PROGRAM_APP_ID, PROGRAM.MAJOR_ID as MAJOR1, ENROLLOBJ.ABBRV as ENROLL from PROGRAM, ENROLLOBJ where PROGRAM.ENROLLOBJ_ID = ENROLLOBJ.ID) ON PROGRAM_APP_ID = APPLICANT.ID JOIN (select APPLICANT_GARGROUP.APPLICANT_ID as APP_GARGROUP, APPLICANT_GARGROUP.GARGROUP_ID as GAR_GROUP_ID from APPLICANT_GARGROUP where APPLICANT_GARGROUP.GARGROUP_ID = 44) ON APP_GARGROUP = APPLICANT.ID LEFT JOIN (select GENDER.NAME as GENDERNAME, GENDER.ID as GENDERID from GENDER) ON (GENDERID = APPLICANT.GENDER_ID) LEFT JOIN (select ETHNICITY.NAME as ETHNICITYNAME, ETHNICITY.ID as ETHNICITYID from ETHNICITY) ON (ETHNICITYID = APPLICANT.ETHNICITY_ID) LEFT JOIN (select COUNTRY.NAME as COUNTRYNAME, CITIZENSHIP.ID as CITID, REGION.NAME as RNAME from COUNTRY, REGION, CITIZENSHIP where CITIZENSHIP.COUNTRY_ID = COUNTRY.ID and COUNTRY.REGION_ID = REGION.ID) ON (CITID = APPLICANT.CITIZENSHIP_ID) LEFT JOIN (select APPLICANT_STATUS.APPLICANT_ID as SAPP_ID, STATUS.NAME as SNAME from STATUS, APPLICANT_STATUS where APPLICANT_STATUS.STATUS_ID = STATUS.ID and APPLICANT_STATUS.GARGROUP_ID = 44) ON SAPP_ID = APPLICANT.ID LEFT JOIN (select APPLICANT_SUPPORT.APPLICANT_ID as SUPAPP_ID, SUPPORT.NAME as SUPNAME from SUPPORT, APPLICANT_SUPPORT
...
and it just keeps going...but i've narrowed the problem down to something in that general area....

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

UserNotFound posted:

I have an SQL statement that is AT LEAST twice as long as the 5000 character limit per post, and there's an error in it somewhere:

....
...
and it just keeps going...but i've narrowed the problem down to something in that general area....

This doesn't look good:
code:
"RNAME" = 'China'SELECT 
edit: there are a few occurrences of this, did something get screwed up when you posted it?

spiritual bypass
Feb 19, 2008

Grimey Drawer

UserNotFound posted:

I have an SQL statement that is AT LEAST twice as long as the 5000 character limit per post, and there's an error in it somewhere:

What's this thing supposed to do?
Is the database itself as horrible as this query?

clockwork automaton
May 2, 2007

You've probably never heard of them.

Fun Shoe
Heard from an undergrad discussing the decompiling of a professors class files: "I don't wanna steal his code and turn it in. I just want to look at the comments to get a better idea how to code it."

MagneticWombats
Aug 19, 2004
JUMP!

clockwork automaton posted:

Heard from an undergrad discussing the decompiling of a professors class files: "I don't wanna steal his code and turn it in. I just want to look at the comments to get a better idea how to code it."

Hey, I'm submitting byte code comments as something to put into the next java standard.

EDIT: He'd also have to understand/learn JVM byte code 0_0

floWenoL
Oct 23, 2002

clockwork automaton posted:

Heard from an undergrad discussing the decompiling of a professors class files: "I don't wanna steal his code and turn it in. I just want to look at the comments to get a better idea how to code it."

Honestly if I were a professor and I found out my student went through the effort of decompiling my reference program and then rewriting it sensibly in the original language, I'd let it go because he probably did learn whatever he was supposed to, and then some.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

floWenoL posted:

Honestly if I were a professor and I found out my student went through the effort of decompiling my reference program and then rewriting it sensibly in the original language, I'd let it go because he probably did learn whatever he was supposed to, and then some.

Eh, it depends. If a student manually inspected bytecode or assembly language code and rewrote it in the original language, then yes, I'd be impressed by that and would congratulate the student instead of punishing them. But if he's just running Jad or Reflector.NET, those generate reasonable enough code automatically that it's not worthy of any kind of praise.

floWenoL
Oct 23, 2002

Flobbster posted:

Eh, it depends. If a student manually inspected bytecode or assembly language code and rewrote it in the original language, then yes, I'd be impressed by that and would congratulate the student instead of punishing them. But if he's just running Jad or Reflector.NET, those generate reasonable enough code automatically that it's not worthy of any kind of praise.

Good point. I'm actually not familiar with the state of decompilers for languages like Java/C#. How readable does "reasonable" look? Are variable names preserved?

SwimNurd
Oct 28, 2007

mememememe

floWenoL posted:

Good point. I'm actually not familiar with the state of decompilers for languages like Java/C#. How readable does "reasonable" look? Are variable names preserved?

I only have experience with Jad, but yes variables names are preserved if debugging is turned on.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

SwimNurd posted:

I only have experience with Jad, but yes variables names are preserved if debugging is turned on.

This has been my experience as well, in just about every class file I've had to decompile -- the main project I've been working on for the past couple years is a Frankenstein-like beast built on Apple WebObjects and we've had to resort to using Jad from time to time to hack into WO classes that we need to fix bugs in or change the functionality of where just subclassing isn't an option.

The code that Jad dumps out is usually quite usable, and in many cases, without needing any manual repair. The only times I've seen it fail were in some heavy try/catch situations, or occasionally with complex nested conditionals where it can't figure out the structure and just dumps out labels.

I haven't used Reflector.NET in several years since I don't do .NET anymore, but I seem to remember it generating pretty good C# code too (never bothered with other languages). Since MSIL can be generated by a handful of source languages, there's probably some cases where it gets tricker (like I don't know how good VB (compile) --> MSIL (decompile) --> C# would look), but if you stick to the same source and destination language it's probably on the same level as Jad.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
code:
if(!(status == OK))
{
    POST_ERROR("not OK");
    //...
}
I had to do a double take at the POST_ERROR line because the if statement tested for equality instead of inequality.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

floWenoL posted:

Good point. I'm actually not familiar with the state of decompilers for languages like Java/C#. How readable does "reasonable" look? Are variable names preserved?

As far as C# goes, if you don't run it through Dotfuscator the thing basically looks like you just removed comments.

If you do, then the variable names change to a, b, c, d, etc (so, no change :v: ) or nonprintable characters if you have the full version, but it's still trivial to see your app logic.

MrBishop
Sep 30, 2006

I see what you did there...

Soiled Meat

Wheany posted:

code:
if(!(status == OK))
{
    POST_ERROR("not OK");
    //...
}
I had to do a double take at the POST_ERROR line because the if statement tested for equality instead of inequality.

I'd punch someone in the face if I had to maintain that. It's the code equivalent of, "Everything's ok...... NOT!!".

Adbot
ADBOT LOVES YOU

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
From the wild west days before static imports:
code:
interface BlahConstants
{
    static final int ITS_A_CONSTANT = 0xffffffff;
    // Repeat a few hundred times
    // There are no methods in this interface
}
code:
class ManIsureDoNeedSomeConstantsButDoNotEnjoyTyping implements BlahConstants
{

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply