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
pseudorandom name
May 6, 2007

Red apples are basically impossible to obtain without cheating anyway, so moaning about the gold cost to craft a golden apple is pointless.

Adbot
ADBOT LOVES YOU

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!
http://forums.somethingawful.com/showthread.php?threadid=3430275

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog
Here's a loop counter increment code written by a major .NET CMS vendor's consulting arm:

System.Math.Max(System.Threading.Interlocked.Increment(ref j), j - 1);

No, there is no assignment. Math.Max() is called for no reason. Because sometimes j += 1 is just too simple.

TasteMyHouse
Dec 21, 2006
code:
 void wasteTime( int n ) 
{ 
   int m = n; 
   int v; 
   int i; 
  
   for ( i = 0; i < 400; i++ ) { 
     v = 0; 
     n = m; 
     while ( n-- ) v += 11; 
   } 
}

:confused:

There's also this, from the same programmer:

code:
if ( MACRO_DEFINING_A_MASK_SHIFT_VALUE != 28 ) printf( "!!!!!!!! SHIFT != 28\n"     );
a = offset + ADDRESS_OF_REGISTER;
v = *((volatile uint32_t *) a);
v &= 0x0FFFFFFF; //the god-damned mask mentioned before as a literal
v |= 0x10000000; 
No idea what he was thinking here -- "I'll check to see if the value matches the literal I use below, and if not I will print a message saying that it doesn't match but still use the (known bad) value"? He had no excuse for using a literal mask, because there's a macro defining that register's mask for all of its bitfields! and he does this everywhere he needed to perform this kind of register operation -- I've found it at least 10 separate times so far.

Tamba
Apr 5, 2010

TasteMyHouse posted:

code:
 void wasteTime( int n ) 
{ 
   int m = n; 
   int v; 
   int i; 
  
   for ( i = 0; i < 400; i++ ) { 
     v = 0; 
     n = m; 
     while ( n-- ) v += 11; 
   } 
}

:confused:
That's obviously a Speed-up Loop

floWenoL
Oct 23, 2002

Extreme negative code documentation.

quote:

The idea of Extreme Negative Code Documentation (ENCD), is that for every line in your code, write a comment explaining what would be wrong with the code if that line was missing.

code:
    # initialise with un-initialised entries
    #N Without initialize, @entries required for getEntries won't be initialised
    def initialize
      #N If we don't pre-set @entries to nil, we won't know that we haven't yet initialised that value
      @entries = nil
    end

shodanjr_gr
Nov 20, 2007

floWenoL posted:

Extreme negative code documentation.


code:
    # initialise with un-initialised entries
    #N Without initialize, @entries required for getEntries won't be initialised
    def initialize
      #N If we don't pre-set @entries to nil, we won't know that we haven't yet initialised that value
      @entries = nil
    end

This reminds me of this practice that a cooworker who worked for a defence contractor mentioned.

Unit tests.

For every. Single. Line. Of. Code. Individually.

He might have been exageratting, but still.

Zhentar
Sep 28, 2003

Brilliant Master Genius

Tamba posted:

That's obviously a Speed-up Loop

That appears to have been obfuscated to prevent the compiler from optimizing it to a noop.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

shodanjr_gr posted:

This reminds me of this practice that a cooworker who worked for a defence contractor mentioned.

Unit tests.

For every. Single. Line. Of. Code. Individually.

He might have been exageratting, but still.

http://ruby.sadi.st/Heckle.html

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

shodanjr_gr posted:

This reminds me of this practice that a cooworker who worked for a defence contractor mentioned.

Unit tests.

For every. Single. Line. Of. Code. Individually.

He might have been exageratting, but still.
http://www.sqlite.org/testing.html

Unit tests for every branch.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Aleksei Vasiliev posted:

http://www.sqlite.org/testing.html

Unit tests for every branch.
that is a lot of loving tests

TasteMyHouse
Dec 21, 2006
from that page:

quote:

It is (relatively) easy to build an SQL database engine that behaves correctly on well-formed inputs on a fully functional computer.

"an SQL"? I thought everyone pronounced it "Sequel".

Toady
Jan 12, 2009

TasteMyHouse posted:

"an SQL"? I thought everyone pronounced it "Sequel".

The official pronunciation is to say the letters.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
it's only pronounced "sequel" when you're saying microsoft sequel server (which uses tee ess cue ell)

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

Plorkyeran posted:

it's only pronounced "sequel" when you're saying microsoft sequel server (which uses tee ess cue ell)

Whether or not that's the way it's supposed to be, it's absolutely not true in reality.

Zamujasa
Oct 27, 2010



Bread Liar
I think my favorite was when some update Notch released had some issue that would randomly crash clients.

Turns out the fix was to wrap the offending code in a try-catch block. :pseudo:


As for MySQL, Lua seems to have the opposite problem where a few people pronounce it "L-U-A" when it's actually pronounced "loo-ah".

From Wikipedia:

quote:

SQL was adopted as a standard by the American National Standards Institute (ANSI) in 1986 as SQL-86[23] and the International Organization for Standardization (ISO) in 1987. The original SQL standard declared that the official pronunciation for SQL is "es queue el".[6] Many English-speaking database professionals still use the nonstandard[24] pronunciation /ˈsiːkwəl/ (like the word "sequel").

I personally use them fairly interchangeably depending on what the person I'm talking to is using.

nielsm
Jun 1, 2009



Zamujasa posted:

As for MySQL, Lua seems to have the opposite problem where a few people pronounce it "L-U-A" when it's actually pronounced "loo-ah".

That annoys the crap out of me. It's not a goddamn abbreviation, it's a word. (Portuguese for moon.) "Oh, name of a language and it's three letters, must be a TLA."

ReelBigLizard
Feb 27, 2003

Fallen Rib

Eggnogium posted:

Whether or not that's the way it's supposed to be, it's absolutely not true in reality.

I call it 'Squeal'...

Che Delilas
Nov 23, 2009
FREE TIBET WEED

nielsm posted:

That annoys the crap out of me. It's not a goddamn abbreviation, it's a word. (Portuguese for moon.) "Oh, name of a language and it's three letters, must be a TLA."

Never knew this (not that I ever used the language), but that quote is a pretty reasonable conclusion if you don't know, is it not? Especially if you don't speak Portuguese.

quote:

SQL

I know the "proper" way but I also tend to just mimic whoever I'm talking to to avoid cognitive hiccups.

Sewer Adventure
Aug 25, 2004
I'm developing an iOS application and decided to use JSONKit for JSON since it is supposedly the fastest library for that purpose.

Various client requirements have resulted in adding plugins for things, including:


It turns out that they each contain a different JSON library. So now the app links to four different JSON libraries: UVJSON (which is just a renamed SBJSON), SBJSON, CJSON and JSONKit

ToxicFrog
Apr 26, 2008


Che Delilas posted:

Never knew this (not that I ever used the language), but that quote is a pretty reasonable conclusion if you don't know, is it not? Especially if you don't speak Portuguese.

I guess, except that in all of the documentation, websites that discuss it, etc it's written "Lua" and not "LUA".

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Aleksei Vasiliev posted:

http://www.sqlite.org/testing.html

Unit tests for every branch.

:drat:

Also, Emm Ess Ess Cue Ell but only because we've had a lot of back-and-forth lately with some nontechnical people lately over which database we actually use around here. "No, we won't support MySqueal alongside the real database."

csammis
Aug 26, 2003

Mental Institution

Munkeymon posted:

:drat:

Also, Emm Ess Ess Cue Ell but only because we've had a lot of back-and-forth lately with some nontechnical people lately over which database we actually use around here. "No, we won't support MySqueal alongside the real database."

We support MSSQL and Oracle where I work. I use Emm Ess Ess Cue Ell and Sequel Server pretty much interchangeably for that product, Tee Ess Cue Ell for the Microsoft language, Pee Ell Ess Cue Ell for the Oracle language, and Sequel Developer for the Oracle tool v:shobon:v

Never have I heard anyone pronounce it Squeal and I hope I never do. I'd probably think it was either a new scripting language that I'd never heard of or some notification tool like Growl.

TasteMyHouse
Dec 21, 2006
If I heard someone say "Squeal" I am certain I'd confuse that for "Squeak".

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



I never used Squeal in a meeting or anything - just to insult MySQL when talking to the admins who need to be reassured they won't have to step too far outside the Microsoft box. You should have heard the scoffing (actual scoffing noises were actually made) when I explained that we had to install the IIS PHP stack for a project that marketing decided was super critical.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Munkeymon posted:

I never used Squeal in a meeting or anything - just to insult MySQL when talking to the admins who need to be reassured they won't have to step too far outside the Microsoft box. You should have heard the scoffing (actual scoffing noises were actually made) when I explained that we had to install the IIS PHP stack for a project that marketing decided was super critical.

Well I wouldn't want php on my server regardless but not because of lack of comfort in using it... quite the opposite in fact.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Scaramouche posted:

Well I wouldn't want php on my server regardless but not because of lack of comfort in using it... quite the opposite in fact.

Only marketing is happy with this, trust me :smith:

Zombywuf
Mar 29, 2008

Munkeymon posted:

Only marketing is happy with this, trust me :smith:

At my last company the deal was "Operations can use a PHP based CMS for a marketing project so long as the devs never have to touch it."

angrytech
Jun 26, 2009

ReelBigLizard posted:

I call it 'Squeal'...

I think you mean "Squirrel".
Oh poo poo, squirrelservone is down again!

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

Zombywuf posted:

At my last company the deal was "Operations can use a PHP based CMS for a marketing project so long as the devs never have to touch it."

My company was offered a free CI solution, which included support and the goodwill of a contact, and they had to do some serious soul searching about whether to use it because it was made in PHP.
EDIT: They still haven't decided.

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Zombywuf posted:

At my last company the deal was "Operations can use a PHP based CMS for a marketing project so long as the devs never have to touch it."

I get to support it because I'm the only one who will admit to knowing anything about PHP other than that it's terrible. Thankfully, I don't have to take the marketing director's code and make it not suck poo poo because we outsourced that. The guy doesn't understand loops and uses PHP. Use your imagination and I guarantee reality was worse.

zeekner
Jul 14, 2007

Munkeymon posted:

I get to support it because I'm the only one who will admit to knowing anything about PHP other than that it's terrible. Thankfully, I don't have to take the marketing director's code and make it not suck poo poo because we outsourced that. The guy doesn't understand loops and uses PHP. Use your imagination and I guarantee reality was worse.

Isolate that box from the network and name it Tortuga, there ain't no way that whore will stay clean.

Zombywuf
Mar 29, 2008

Munkeymon posted:

I get to support it because I'm the only one who will admit to knowing anything about PHP other than that it's terrible. Thankfully, I don't have to take the marketing director's code and make it not suck poo poo because we outsourced that. The guy doesn't understand loops and uses PHP. Use your imagination and I guarantee reality was worse.

Are you sure I can imagine some pretty terrible things, and by imagine I mean remember. And by remember I mean suffer crippling flashbacks.


Also, have some awful code (names changed to protect the guilty):
code:
if (key == "cstrPageSubTitle_Location_UK")
  return "Cheap deals from $$location$$";
else
  return CustomResourceManager.getStringForLanguageByKey(key, languageContext);

NotShadowStar
Sep 20, 2000
Aside from not using {} around conditionals in a language with braces, we're going to need some context for that one.

Zombywuf
Mar 29, 2008

NotShadowStar posted:

Aside from not using {} around conditionals in a language with braces, we're going to need some context for that one.

You have a thing to look up strings based on a key and a language, except for that key, which for some reason has a country attached to it and a hardcoded value. Add to that the fact that everything has an awful name.

EDIT: Also, that's about 20 calls up the stack, and you know that something below it has already done some hardcoded poo poo but finding it will take a week. There is also about another 20 layers to go up before you get to the framework provided language resource lookup mechanism that does the same thing a thousand times better.

All in all, this is part of a codebase that takes about 1s of CPU time just to render a page.

Zombywuf fucked around with this message at 19:54 on Sep 23, 2011

epitaph
Dec 31, 2008
Found this gem while randomly going through some code used by my former employer:

code:
    this.UrlEncode = function (url) {
        return url.replace(/%/g, '%25').replace(/&/g, '%26').
                    replace(/=/g, '%3d').replace(/#/g, '%23').
                    replace(/\+/g, '%2b');
    }

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I'm brushing up on C and networking stuff. The quality of example code online is great:

code:
printsin( sin, m1, m2 )
struct sockaddr_in *sin;
char *m1, *m2;
{
    struct hostent *gethostbyaddr(), *h;

    printf ("%s %s:\n", m1, m2);
    printf ("  family %d addr %x port %d\n", sin -> sin_family,
	    sin -> sin_addr.s_addr, sin -> sin_port);
}
There are just layers to this. Does anybody still intentionally write method signatures like that? What is the deal with that hostent pointer?

NotShadowStar
Sep 20, 2000

epitaph posted:

Found this gem while randomly going through some code used by my former employer:

code:
    this.UrlEncode = function (url) {
        return url.replace(/%/g, '%25').replace(/&/g, '%26').
                    replace(/=/g, '%3d').replace(/#/g, '%23').
                    replace(/\+/g, '%2b');
    }

Because they didn't use encodeURI()?

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

Internet Janitor posted:

I'm brushing up on C and networking stuff. The quality of example code online is great:
There are just layers to this. Does anybody still intentionally write method signatures like that? What is the deal with that hostent pointer?

It still surprises me when I see bits of K&R C around, though that's when it's part of a large codebase which has been around since the old days.
I can understand the what of the hostent pointer stuff, (declaring a function and pointer), but not the why as neither are used.
I've never really understood why you'd want to declare a function in the body of another function anyway.

Adbot
ADBOT LOVES YOU

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I just rewrote the whole mess as:
code:
void printsin(struct sockaddr_in* sin, char* m1, char* m2) {
	printf("%s %s:\n", m1, m2);
	printf("  family %d addr %x port %d\n",
		sin -> sin_family,
		sin -> sin_addr.s_addr,
		sin -> sin_port
	);
}

Internet Janitor fucked around with this message at 23:16 on Sep 24, 2011

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