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
whiskas
May 30, 2005
If any of you have ever used infragistics this is all too common:

Adbot
ADBOT LOVES YOU

Rottbott
Jul 27, 2006
DMC

void RaceCollision(_Bool Collide)
{
if (Collide)
{
CleanRace = FALSE;
CleanLap = FALSE;
}
}


Called from exactly one place in the entire game, with the parameter set to TRUE. It even had a completely useless timer on it to stop it being called repeatedly during an ongoing collision.

G-Dub
Dec 28, 2004

The Gonz
I don't have code snippets but I have recently been given the privilege of taking over development of a local intranet system in my work. The previous developer has apparent never heard of :hover, which means the navigation (table rows, naturally) is filled with javascript changing the style from a class called A to a class called AHover onmouseover, and of course back to A onmouseout.

I was speechless upon perusing the code. Am I being naive here and there was a time where Javascript had developed faster than CSS and therefore :hover didn't exist and this was the only way to do it? Even if such a time existed this was developed only 2 years ago so it's inexcusable.

Finally, when opening the site instead of just opening an HTML file you open an HTA file, which is apparently an HTML Application. Is this ever excusable?

Thankfully I am close to getting the goahead to start from scratch. Unfortunately they are not very willing to give me a (L)AMP setup :(

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

G-Dub posted:

Finally, when opening the site instead of just opening an HTML file you open an HTA file, which is apparently an HTML Application. Is this ever excusable?

Maybe it's doing some really cool fuckery that you can't do with non-application HTML.

I don't have a clue what such fuckery would look like, but who am I to say it doesn't exist.

biznatchio
Mar 31, 2001


Buglord

pokeyman posted:

Maybe it's doing some really cool fuckery that you can't do with non-application HTML. I don't have a clue what such fuckery would look like, but who am I to say it doesn't exist.

I've used more than a couple HTAs. Javascript running in an HTA has pretty much full system access -- if you can do it with a standalone .js file running through the Windows Scripting Host, you can do it in an HTA.

Local files, printers, system administration, and Office automation (well, any COM automation) are all examples of reasons you'd want an HTA; and since an HTA can include an IFRAME and optionally pass full application-level permission to it, it allows you to grant those extended privileges to any arbitrary URL of your choice, so you can host your actual application logic on a web server somewhere for easy maintenance.

Anonymous Name
Apr 25, 2006

by Fragmaster

G-Dub posted:

I don't have code snippets but I have recently been given the privilege of taking over development of a local intranet system in my work. The previous developer has apparent never heard of :hover, which means the navigation (table rows, naturally) is filled with javascript changing the style from a class called A to a class called AHover onmouseover, and of course back to A onmouseout.

I was speechless upon perusing the code. Am I being naive here and there was a time where Javascript had developed faster than CSS and therefore :hover didn't exist and this was the only way to do it? Even if such a time existed this was developed only 2 years ago so it's inexcusable.
My websites use javascript instead of hover. IE does or did not support hover, and/or it does not for all elements.

Rottbott posted:


void RaceCollision(_Bool Collide)
{
if (Collide)
{
CleanRace = FALSE;
CleanLap = FALSE;
}
}


Called from exactly one place in the entire game, with the parameter set to TRUE. It even had a completely useless timer on it to stop it being called repeatedly during an ongoing collision.
Could be worse - he could have passed FALSE. :)

Anonymous Name fucked around with this message at 03:55 on Aug 22, 2008

MononcQc
May 29, 2007

Anonymous Name posted:

My websites use javascript instead of hover. IE does or did not support hover, and/or it does not for all elements.

IE7 does, and for IE5/6, the solution is csshover.htc.

code:
body { 
    behavior:url("csshover.htc"); 
}
It may pop an ActiveX thing on the top of the browser, though, but I guess it's worth it for the clean markup.

sklnd
Nov 26, 2007

NOT A TRACTOR
This isn't so much a coding horror as it is a process horror. We're out of development and feature integration testing (where developers have pretty free reign over what gets checked in and put into the weekly build), and started a large test cycle two weeks ago. In test, all changes have to be associated with a bug and approved by a change control board.

I'm the build monkey, so I look at all the changes made and make sure they're associated with a bug and a note has been put into the release notes we generate each week.

One of our developers checked in a file with the comment "Prettier code". I've been burned by little changes made by this particular person in the past, when he went on vacation just before the build was done, and a small logging change broke some major functionality in our product. I had to dig in and fix it, and it wasn't a huge deal, but I now diff a lot of his smaller check-ins to make sure I understand what's going in each week and that its not busted. (I don't have time or patience to code-review the bigger stuff)

The prettier code:
code:
*(unsigned*)mVarName = varname;
became
code:
*(unsigned*)&mVarName[0] = varname;
:pseudo:

The guy's a great developer and has lots of experience and all, but getting the guy to abide by a little bit of process is like herding cats.

Fenderbender
Oct 10, 2003

You have the right to remain silent.
Edit: Disregard what was here. I've compiled a nice list during this development cycle I'll post.

beuges
Jul 4, 2005
fluffy bunny butterfly broomstick
Since enum's always increment by 1 unless you specify a value, maybe somebody can explain why the Windows Media Player sdk headers are full of stuff like this?

code:
typedef /* [public][helpstring] */ 
enum WMPPlayState
    {	wmppsUndefined	= 0,
	wmppsStopped	= ( wmppsUndefined + 1 ) ,
	wmppsPaused	= ( wmppsStopped + 1 ) ,
	wmppsPlaying	= ( wmppsPaused + 1 ) ,
	wmppsScanForward	= ( wmppsPlaying + 1 ) ,
	wmppsScanReverse	= ( wmppsScanForward + 1 ) ,
	wmppsBuffering	= ( wmppsScanReverse + 1 ) ,
	wmppsWaiting	= ( wmppsBuffering + 1 ) ,
	wmppsMediaEnded	= ( wmppsWaiting + 1 ) ,
	wmppsTransitioning	= ( wmppsMediaEnded + 1 ) ,
	wmppsReady	= ( wmppsTransitioning + 1 ) ,
	wmppsReconnecting	= ( wmppsReady + 1 ) ,
	wmppsLast	= ( wmppsReconnecting + 1 ) 
    } 	WMPPlayState;

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.
Either the headers date back to some ancient and barely-standard-conforming VC, were tool-generated, or were jerk-generated.

mynameisntneo
Sep 12, 2006
Mr. Anderson
$condition and $other_condition are always true or false.

php:
<?
  if($condition ? true : $other_condition) {
    do_something();
  }
?>
Why isn't || good enough?

StickGuy
Dec 9, 2000

We are on an expedicion. Find the moon is our mission.

mynameisntneo posted:

Why isn't || good enough?
It's not optimized savagely enough.

Karanth
Dec 25, 2003
I need to finish Xenogears sometime, damn it.

Mustach posted:

Either the headers date back to some ancient and barely-standard-conforming VC, were tool-generated, or were jerk-generated.

Ever actually watch someone write C++ by VC6 wizard? Using the mouse more than the keyboard?

It is one of the most surreal and depressing experiences I've ever had. :smith:

Arconom
Jun 27, 2006
Edouard Joseph Gilliath 1417 - 1460 Battle of Arkinholm risen again to protect
code:
020-DRIVER.
    MOVE "DRIVER" TO DML-ERR-PARA.
    IF WS-OPT = 'P' OR 'L'
       GO FIND-EQPP
    ELSE
       GO FIND-ACFT
    END-IF.

    PERFORM PROCESS-EQPP.

    IF EQPP-NOT-VALID
       GO SOMEOTHERPROGRAM
    ELSE
       GO PRINT-EQPP
    END-IF.
I really hate maintaining COBOL. It's very tedious trying to figure out where someone's logic is going. Most of the time I spend on a problem is tracing logic backward and forward, from one program to another, hoping the procession of go to statements will someday come to an end.


edit: For some reason my indentation isn't showing up.
edit: Awesome...[code] tags are cool. You can tell I don't use tags very often/at all

Arconom fucked around with this message at 04:56 on Aug 27, 2008

Sivart13
May 18, 2003
I have neglected to come up with a clever title

Arconom posted:

edit: For some reason my indentation isn't showing up.
Put it in [code] tags.

I get the feeling even posting the best-written COBOL you could find would still be valid for this thread.

Munkeymon
Aug 14, 2003

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



Sivart13 posted:

I get the feeling even posting the best-written COBOL you could find would still be valid for this thread.

Actually, if this:
code:
IF WS-OPT = 'P' OR 'L'
does what it looks like it does, then that's kind of nice, actually. Explicitly writing out things like if(something == A || something == F) always kind of bugged me for some reason.

Arconom
Jun 27, 2006
Edouard Joseph Gilliath 1417 - 1460 Battle of Arkinholm risen again to protect
COBOL has its neat features, but its archaic structure and design more than make up for it. I haven't used OOCOBOL yet. Maybe it will be pretty cool.

Thots and Prayers
Jul 13, 2006

A is the for the atrocious abominated acts that YOu committed. A is also for ass-i-nine, eight, seven, and six.

B, b, b - b is for your belligerent, bitchy, bottomless state of affairs, but why?

C is for the cantankerous condition of our character, you have no cut-out.
Grimey Drawer

Munkeymon posted:

Actually, if this:
code:
IF WS-OPT = 'P' OR 'L'
does what it looks like it does, then that's kind of nice, actually. Explicitly writing out things like if(something == A || something == F) always kind of bugged me for some reason.
When I was a Junior Programmer, this was always my biggest pet peeve. The former is so natural I could never understand why it wasn't supported more.

I've been beaten down by code for so long I've almost forgotten how wonderful those early days were.

ashgromnies
Jun 19, 2004

Zaasakokwaan posted:

When I was a Junior Programmer, this was always my biggest pet peeve. The former is so natural I could never understand why it wasn't supported more.

I've been beaten down by code for so long I've almost forgotten how wonderful those early days were.

Wouldn't that kill the English readability of something like:

code:
if ($user->is_valid() && $user->has_enough_money()){
though? You'd need to make it

code:
if ($user->is_valid() == 1 && $user->has_enough_money() == 1){
which I don't like! It kills the readability of boolean expressions, and I'm also not sure of how it would work in dynamic languages where if($var) and if($var == 1) are completely different.

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.
That's what the "in" operator's for. "if ws_opt in ['p', 'l']"

Midelne
Jun 19, 2002

I shouldn't trust the phones. They're full of gas.

Sivart13 posted:

I get the feeling even posting the best-written COBOL you could find would still be valid for this thread.

I only work with three COBOL applications, but they're made by different companies and all of them have between sixty and two hundred uncommented batch files that are absolutely necessary for regular operation that are labeled between 1.bat and 200.bat.

Munkeymon
Aug 14, 2003

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



ashgromnies posted:

Wouldn't that kill the English readability of something like:

code:
if ($user->is_valid() && $user->has_enough_money()){
though? You'd need to make it

code:
if ($user->is_valid() == 1 && $user->has_enough_money() == 1){
which I don't like! It kills the readability of boolean expressions, and I'm also not sure of how it would work in dynamic languages where if($var) and if($var == 1) are completely different.

I was thinking a shorthand just for this case:
code:
if(mode == [1 | 2 | 3 | 5 | 8])
So ==[] is like a new operator that's really just syntactic sugar for the condition checks the compiler is going to emit anyway. That's just a quick example, though. I haven't given much thought to the 'best' way to do it.

Volte
Oct 4, 2004

woosh woosh

Munkeymon posted:

I was thinking a shorthand just for this case:
code:
if(mode == [1 | 2 | 3 | 5 | 8])
So ==[] is like a new operator that's really just syntactic sugar for the condition checks the compiler is going to emit anyway. That's just a quick example, though. I haven't given much thought to the 'best' way to do it.
Well some languages like Python have an 'in' operator. Like
code:
if mode in [1, 2, 3, 5, 8]

Munkeymon
Aug 14, 2003

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



Volte posted:

Well some languages like Python have an 'in' operator. Like
code:
if mode in [1, 2, 3, 5, 8]

I know, but I was specifically thinking of C-style languages where ==[] might look more at home in a conditional. Also, JavaScript and C# already use in for other things.

enki42
Jun 11, 2001
#ATMLIVESMATTER

Put this Nazi-lover on ignore immediately!

Munkeymon posted:

I know, but I was specifically thinking of C-style languages where ==[] might look more at home in a conditional. Also, JavaScript and C# already use in for other things.

It's actually pretty easy to hack up an extension method on Object for in if you really want it. I think this should work:

code:
public static bool In(this object toCompare, object[] otherObjects) {
   return otherObjects.Contains(toCompare);
}
And you can throw a couple of extra overloads to avoid the ugly array instantiation syntax:

code:
public static bool In(this object toCompare, object o1, object o2) {
   return In(new object[] {o1, o2};
}
public static bool In(this object toCompare, object o1, object o2, object o3) {
   return In(new object[] {o1, o2, o3};
}
etc.
Then just use:

code:
if (a.In(1,2,3)) {
  // do stuff.
}

// array way
if (a.In(new object[] {1,2,3,4,5}) {
   // do stuff
}

POKEMAN SAM
Jul 8, 2004

enki42 posted:

It's actually pretty easy to hack up an extension method on Object for in if you really want it. I think this should work:

code:
public static bool In(this object toCompare, object[] otherObjects) {
   return otherObjects.Contains(toCompare);
}
And you can throw a couple of extra overloads to avoid the ugly array instantiation syntax:

Assuming this is C# and not Java (I still can't tell the difference, heh) then you don't need the overloads. You can do:

code:
public static bool In(this object toCompare, [b]params[/b] object[] otherObjects) {
   return otherObjects.Contains(toCompare);
}
Then you can just call Whatever.In(1,2,3,4,5) with however many you parameters you want.

No Safe Word
Feb 26, 2005

Ugg boots posted:

Assuming this is C# and not Java (I still can't tell the difference, heh) then you don't need the overloads. You can do:

code:
public static bool In(this object toCompare, [b]params[/b] object[] otherObjects) {
   return otherObjects.Contains(toCompare);
}
Then you can just call Whatever.In(1,2,3,4,5) with however many you parameters you want.
Monkeypatching FTL.

Arconom
Jun 27, 2006
Edouard Joseph Gilliath 1417 - 1460 Battle of Arkinholm risen again to protect
code:
Evaluate true
    When ws-opt = 'P'
    When ws-opt = 'R'
         move goonz to outside
    When other
         move yo-rear end to tha-kitchen
end-evaluate.
Evaluate is awesome

Scaevolus
Apr 16, 2007

No Safe Word posted:

Monkeypatching FTL.
How is this monkeypatching?

No Safe Word
Feb 26, 2005

Scaevolus posted:

How is this monkeypatching?

The this <typename> construct in C# is basically their way of instituting monkeypatching. They call it "extension methods" but it's the same thing, anything that includes that method's namespace gets those methods tacked on to whatever object it applies to. The only good thing that C# does instead is it doesn't allow you to override stuff, but that only makes the idea of monkeypatching slightly less crappy.

KaeseEs
Feb 23, 2007

by Fragmaster

No Safe Word posted:

The this <typename> construct in C# is basically their way of instituting monkeypatching. They call it "extension methods" but it's the same thing, anything that includes that method's namespace gets those methods tacked on to whatever object it applies to. The only good thing that C# does instead is it doesn't allow you to override stuff, but that only makes the idea of monkeypatching slightly less crappy.

Thta's not what monkeypatching is, and don't say 'FT[WL]', this isn't slashdot

Munkeymon
Aug 14, 2003

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



Damnit, guys. Quit bringing practical solutions to my fantasy land.

No Safe Word posted:

Monkeypatching FTL.

I don't know that it counts as monkeypatching but I still like it less than adding some shorthand to the language.

And where the hell is your avatar from?

No Safe Word
Feb 26, 2005

KaeseEs posted:

Thta's not what monkeypatching is, and don't say 'FT[WL]', this isn't slashdot

Thanks for the geography lesson. And for the complete lack of clarification on what you think monkeypatching actually is. And for being the post police in a light-hearted thread.

Hacking methods into a class that you didn't create is, in my mind, monkeypatching. Whether it's tacking on a method or redefining an existing one.

code:
public static string this_is_not_slashdot(this string src)
{
    return src + "FTL LOL";
}

public void some_method()
{
    string s = "Something awful dot com";
    s.this_is_not_slashdot();  // wow, the core string class has a new method that
                               // won't show up in any of the core string docs!
}
edit:

Munkeymon posted:

And where the hell is your avatar from?
SNL's Digital Short "Dear Sister", I made the animation myself from screencaps

I forgot I had it because I browse with avatars off at work :)

No Safe Word fucked around with this message at 18:04 on Aug 27, 2008

KaeseEs
Feb 23, 2007

by Fragmaster
For the clinically dumb, monkeypatching involves replacing poo poo. And yes, your hilarious reference to hollywood squares was both timely and enjoyable

Munkeymon
Aug 14, 2003

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



No Safe Word posted:

Hacking into a class that you didn't create is, in my mind, monkeypatching. Whether it's tacking on a method or redefining an existing one.

The super official Wikipedia definition says it has to happen at run time which may or may not be the case depending on how they do the magic in the IL. At any rate, wouldn't that method show up in CodeSense and be type cheched at compile time, making it signifigantly safer and more visible than the traditional monkeypatch?

quote:

edit:

SNL's Digital Short "Dear Sister", I made the animation myself from screencaps

I forgot I had it because I browse with avatars off at work :)

Thanks, now I'll ahve to go check it out.

KaeseEs
Feb 23, 2007

by Fragmaster
Done making GBS threads on the thread, here's a classic from php land, quoted from elsewhere:

http://use.perl.org/~Aristotle/journal/33448 posted:

This is a tale of an integer overflow vulnerability (paraphrased for the purposes of the tale, as are all following snippets):

code:
dest = calloc(EXPR, sizeof(char));
/* where EXPR is a calculation that is never checked for overflow */
Of course, the maintainers of the software in question are studious and busy types and they would not let this go unfixed for long – they instituted a check to make sure that such a thing would never happen again:

code:
int size;

size = EXPR;

if (size > INT_MAX || size <= 0) {
    return NULL;
}

dest = calloc(size, sizeof(char));
Marvelous! Now the code is safe…



Err, right. Undaunted and unphased by having made a mistake, they sagely nodded when they learned of it, and proceeded to implement a fix that would rid the world of this evil for good:

code:
float size;

size = PARTIAL_EXPR_1;
size *= PARTIAL_EXPR_2;
size += PARTIAL_EXPR_3;

if (size > INT_MAX || size <= 0) {
    return NULL;
}

dest = calloc((int)size, sizeof(char));
And the world was a safer pl… err… I mean: and when they also got rid of floating point round-offs, the world became a safer pla…



OK, people, enough of the fairy tales. How do these people even come up with this stuff?!? Testing an integer for whether it’s greater than INT_MAX ?! A float to calculate the length of a string!? I mean… I am… when I…

You can’t even parody this stuff.

This is bogosity as it belongs on DailyWTF, not into one of the most widely deployed codebases on the internet that is backed by several of the biggest corporations in IT. Please, please, someone tell me how PHP got to be as big as it is?

P.S.: oh yeah, and the current guard clause looks like this:

code:
int charsize = sizeof(char);

/* still the same float-based calculation here */

if ((size > INT_MAX || size <= 0) || ((size * charsize) > INT_MAX || (size * charsize) <= 0)) {
    return NULL;
}
Portability is important, after all.


and an encore:
php:
<?
magic_quotes_*()
addslashes()
mysql_escape_string()
mysql_real_escape_string()?>
:psyduck:

Volte
Oct 4, 2004

woosh woosh
I don't consider it monkeypatching because the extension method does not have any access to internal members of the class or indeed any special privileges that do not exist when the method is implemented normally. The extension method has to be in scope (i.e. imported) in order to use it, and I believe it is translated into a traditional function call in the IL. Obviously, it should be used sparingly and be documented well when it is, but it's how things like LINQ are implemented, and it's a real blessing.

Zombywuf
Mar 29, 2008

Munkeymon posted:

Actually, if this:
code:
IF WS-OPT = 'P' OR 'L'
does what it looks like it does, then that's kind of nice, actually. Explicitly writing out things like if(something == A || something == F) always kind of bugged me for some reason.

You want Prolog:
code:
member(Something, [A, F]) -> thenstuff ; elsestuff.
This message brought to you by the Save the Prolog Foundation.

Adbot
ADBOT LOVES YOU

tef
May 30, 2004

-> some l-system crap ->
Re Monkeypatching:

That's nice dearie, can we take this argument and beat it to death in a new thread please? :shobon:

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