Comment On Another Friday Smorgasbord

It's been a while since I've done one of these. There should be something in here for everyone ... [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Another Friday Smorgasbord

2006-07-14 13:50 • by Eric Shinn
Alex Papadimoulis:


Scott Stanchfield was tasked with optimizing memory usage in a Java application and found a way to shave a few bytes left in by an intern with a sense of humor ...


public class ValidationMessage

{
//internal members
string messageId;
string messageText;
string helpLink;
/* ... */
double cheeseburger;
char broiled;
long time;

//helper functions
/* ... */
}



Nice...

Re: Another Friday Smorgasbord

2006-07-14 13:51 • by Maxim Rouiller
public class ValidationMessage
{
//internal members
string messageId;
string messageText;
string helpLink;
/* ... */
double cheeseburger;
char broiled;
long time;

//helper functions
/* ... */
}


LOL

That is a good one!

Re: Another Friday Smorgasbord

2006-07-14 13:52 • by slavdude

And while we're picking on the VS Tools for Office, following is the code required to call Excel's Dialog Show from C# ...


if(xlApp.Dialogs[Excel.XlBuiltInDialog.xlDialogOpen].Show(sTextName,

Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing) == true) { ... }
 
Welcome to Office Interop for .NET.  This joyous thing is in .NET 2003, too.
'M I first?

Re: Another Friday Smorgasbord

2006-07-14 13:52 • by NiggerFromNiger
81694 in reply to 81691
n1 roflskates

Re: Another Friday Smorgasbord

2006-07-14 13:56 • by GoatCheez
Alex Papadimoulis:

Scott Stanchfield was tasked with optimizing memory usage in a Java application and found a way to shave a few bytes left in by an intern with a sense of humor ...


public class ValidationMessage

{
//internal members
string messageId;
string messageText;
string helpLink;
/* ... */
double cheeseburger;
char broiled;
long time;

//helper functions
/* ... */
}


Burger King fan?

Alex Papadimoulis:



Buried inside of a large ACH validation routine, Stefanie found this line ...


if (i == 892)  syscall_beep();


Alex forgot to mention that Stefanie was brought in to figure out why their server was constantly beeping at odd intervals ;-P


Alex Papadimoulis:

The following variable names (submitted by A and O, respectively) are best enjoyed with a maturity age of fourteen years or less ...


float CumRate;  // Cumulative pass rate


...

string ass = Request.Form["associated_skill_"+selId];
if (ass.IndexOf(",") > -1)
{
ass = ass.Split(',')[0];
}
row.ID = int.Parse(ass)



All an essential part of the PrisonCellMate class ;-)


Alex Papadimoulis:

Matt Spicer understands that this following function is called like "EnableDisable(true);" but still wondered exactly what would happen ...


//Enable or disable controls in the form

private void EnableDisable(bool blnEnable) { ... }



Actually, after trying to find something funny to say about this function, it becomes quite obvious what it does.
The function doesn't return a value, and the parameter is not a boolean. Therefore, we can assume that the value
passed is what we want to be done. The name of the parameter is Enable. So, if Enable is true, it enables the
controls. If it is false, it disables it.


Re: Another Friday Smorgasbord

2006-07-14 13:57 • by cynic
Alex Papadimoulis:
public class ValidationMessage

{
//internal members
string messageId;
string messageText;
string helpLink;
/* ... */
double cheeseburger;
char broiled;
long time;

//helper functions
/* ... */
}

If the above is supposed to be written in Java, then it should be String, not string.

Re: Another Friday Smorgasbord

2006-07-14 13:58 • by Erick
public class haveit {}

haveit yourway;

Re: Another Friday Smorgasbord

2006-07-14 13:58 • by kwan3217

Buried inside of a large ACH validation routine, Stefanie found this line ...


if (i == 892)  syscall_beep();




I've done stuff like this in a lot of programs. It's obviously there for debugging, and probably he set a breakpoint on syscall_beep(). There obviously was a problem with thing 892, and in an effort to debug, and not have to trace through the previous 891 things, you put in a line of code with no effect, inside of an if, and break on it.


<obligatory>The real WTF is that they forgot to take it out.</obligatory>

Re: Another Friday Smorgasbord

2006-07-14 14:00 • by bob

>if(xlApp.Dialogs[Excel.XlBuiltInDialog.xlDialogOpen].Show(sTextName,
>  Type.Missing


NOW do we understand why optional params are a bad idea?? Over f'ing load the method, people, I think even VB.NET can handle that. Suppose this was just a COM wrapper though...

Re: Another Friday Smorgasbord

2006-07-14 14:04 • by Otto
81701 in reply to 81697
Anonymous:
If the above is supposed to be written in Java, then it should be String, not string.


While it may have the wrong case there for Java, it is, in fact, perfectly correct C++.

Re: Another Friday Smorgasbord

2006-07-14 14:10 • by GoatCheez
81704 in reply to 81701
Otto:
Anonymous:
If the above is supposed to be written in Java, then it should be String, not string.


While it may have the wrong case there for Java, it is, in fact, perfectly correct C++.


..... assuming that string was defined as a type.... otherwise all fingers point to C# ;-)

Re: Another Friday Smorgasbord

2006-07-14 14:12 • by cconroy
Alex Papadimoulis:
  ass = ass.Split(',')[0];






Best. Line of code. Ever.



Re: Another Friday Smorgasbord

2006-07-14 14:18 • by Ytram
Alex Papadimoulis:


The following variable names (submitted by A and O, respectively) are best enjoyed with a maturity age of fourteen years or less ...


float CumRate;  // Cumulative pass rate


...

string ass = Request.Form["associated_skill_"+selId];
if (ass.IndexOf(",") > -1)
{
ass = ass.Split(',')[0];
}
row.ID = int.Parse(ass)




One of my favorite pieces of code that is similar to this is in the system at my company.  Written by yours truly, it looks a little something like this:

Assessment ass = new Assessment(...);
...
if(ass.Dirty)
{
    ...
}

Re: Another Friday Smorgasbord

2006-07-14 14:19 • by John Bigboote
81708 in reply to 81705
cconroy:
Alex Papadimoulis:
  ass = ass.Split(',')[0];






Best. Line of code. Ever.




I swear, I would have used a pipe delimiter and an x variable for the smooch.

ass = ass.Split('|')[x]

Re: Another Friday Smorgasbord

2006-07-14 14:22 • by John Bigboote
81709 in reply to 81706
Ytram:


One of my favorite pieces of code that is similar to this is in the system at my company.  Written by yours truly, it looks a little something like this:

Assessment ass = new Assessment(...);
...
if(ass.Dirty)
{
    ...
}



I like to come up with creative sub-classes of exception so that I can write things like

catch(BranchOperationRequiredException bare)

and

catch(DuplicateOperationPreventedException dope)

Re: Another Friday Smorgasbord - char broiled

2006-07-14 14:25 • by Bradlegar the Hobbit
God is real, unless declared integer.

Captcha: Pizza.  And I just finished my lunch ...

Re: Another Friday Smorgasbord

2006-07-14 14:26 • by VGR
Alex Papadimoulis:

We've all seen the "const ONE=1" plenty of times, so here's a fun variation that Matthew Farwell
found in cost estimating software. To be fair to the original
programmer, no one could have possibly anticipated that someone,
somewhere, sometime might want to increase prices ...


public final static int V_125 = 155;
public final static int V_165 = 195;
public final static int V_195 = 225;
public final static int V_225 = 255;
public final static int V_255 = 285;
public final static int V_285 = 315;
public final static int V_345 = 375;
public final static int V_405 = 375;
public final static int V_435 = 435;
public final static int V_495 = 495;
public final static int V_555 = 555;
public final static int V_615 = 615;






public class Winston

{

    public static final int TWO_PLUS_TWO = 5;

}

Alex Papadimoulis:
The following variable names (submitted by A and O, respectively) are best enjoyed with a maturity age of fourteen years or less ...


float CumRate;  // Cumulative pass rate
 




In all fairness, I see "cum" used as an abbreviation for "cumulative"
rather often.  I guess I just tune it out after a while. 
Though I personally have a strict policy of avoiding abbrevations as
much as possible, except for very common ones like "XML".

Re: Another Friday Smorgasbord

2006-07-14 14:26 • by juvenile
81713 in reply to 81709

John Bigboote:
Ytram:

One of my favorite pieces of code that is similar to this is in the system at my company.  Written by yours truly, it looks a little something like this:

Assessment ass = new Assessment(...);
...
if(ass.Dirty){ ... }


I like to come up with creative sub-classes of exception so that I can write things like
catch(BranchOperationRequiredException bare)
and
catch(DuplicateOperationPreventedException dope)


Or the ever popular:

catch (WhenTrueFalse wtf) {

// not FileNotFound
}

Re: Another Friday Smorgasbord

2006-07-14 14:28 • by foxyshadis
81714 in reply to 81700
Anonymous:

>if(xlApp.Dialogs[Excel.XlBuiltInDialog.xlDialogOpen].Show(sTextName,
>  Type.Missing


NOW do we understand why optional params are a bad idea?? Over f'ing load the method, people, I think even VB.NET can handle that. Suppose this was just a COM wrapper though...


Yeah, COM is that chunk of Win16 that stubbornly refuses to die, giving up a steady stream of WTF from 1992 to present.

On a vague tangent, I really wish I could find a compiler/preprocessor that supported named arguments in C,  C++, C#, or Java. Everytime I touch win32 code after a month or two elsewhere I come back and end up clueless as to what arguments are doing, especially surrounded by a random number of NULLs.

Re: Another Friday Smorgasbord

2006-07-14 14:29 • by Matt the Greater
81715 in reply to 81709
John Bigboote:


I like to come up with creative sub-classes of exception so that I can write things like

catch(BranchOperationRequiredException bare)

and

catch(DuplicateOperationPreventedException dope)


or maybe:
catch(PriceUnitHolderSelectionException puhse)

Re: Another Friday Smorgasbord

2006-07-14 14:32 • by juvenile
81716 in reply to 81713

Several years ago, we worked on a system that wreaked of buzzword bingo. We had to add a new db table to hold transaction log records, locally called record-of-diary, but all the good acronyms (relevant to the system) were already used. My boss, in a fit of frustration, told the dba to just name the table 'asshole'. He did. Two days later, we started getting nasty e-mails from the operations group complaining about log entries that looked like this:


inserting ROD into asshole ...


*sigh*

Re: Another Friday Smorgasbord

2006-07-14 14:32 • by Matt the Greater
81717 in reply to 81715
Anonymous:
John Bigboote:


I like to come up with creative sub-classes of exception so that I can write things like

catch(BranchOperationRequiredException bare)

and

catch(DuplicateOperationPreventedException dope)


or maybe:
catch(PriceUnitHolderSelectionException puhse)


That's real by the way :)

Re: Another Friday Smorgasbord

2006-07-14 14:37 • by juvenile
81718 in reply to 81717

Anonymous:
Anonymous:
John Bigboote:


I like to come up with creative sub-classes of exception so that I can write things like

catch(BranchOperationRequiredException bare)

and

catch(DuplicateOperationPreventedException dope)


or maybe:
catch(PriceUnitHolderSelectionException puhse)


That's real by the way :)


I get the abbreviation with initials, but what else does puhse stand for?

Re: Another Friday Smorgasbord

2006-07-14 14:38 • by Bus Raker
Alex:




  double cheeseburger;
  char broiled;
  long time;

 byte me;



Alex:

The following variable names (submitted by A and O, respectively) are best enjoyed with a maturity age of fourteen years or less ...


float CumRate;  // Cumulative pass rate


...

string ass = Request.Form["associated_skill_"+selId];
if (ass.IndexOf(",") > -1)
{
ass = ass.Split(',')[0];
}
row.ID = int.Parse(ass)


Butthead:

He said 'Cum' ..... ha ha ha


Beavis:

Yeah 'Cum' ..... ha ha ha


Alex:



Matt Spicer understands that this following function is called like "EnableDisable(true);" but still wondered exactly what would happen ...


//Enable or disable controls in the form

private void EnableDisable(bool blnEnable) { ... }




This is simply a toggle ... no WTF there, except to name it 'private void ToggleControl'

Re: Another Friday Smorgasbord

2006-07-14 14:42 • by Philbert Desanex
81720 in reply to 81718
juvenile:

I get the abbreviation with initials, but what else does puhse stand for?



Two syllables...pronounce it.

Re: Another Friday Smorgasbord

2006-07-14 14:44 • by Dude
81721 in reply to 81718
juvenile:

Anonymous:
Anonymous:
John Bigboote:


I like to come up with creative sub-classes of exception so that I can write things like

catch(BranchOperationRequiredException bare)

and

catch(DuplicateOperationPreventedException dope)


or maybe:
catch(PriceUnitHolderSelectionException puhse)


That's real by the way :)


I get the abbreviation with initials, but what else does puhse stand for?



A cat

Re: Another Friday Smorgasbord

2006-07-14 14:46 • by seymore15074
Alex Papadimoulis:


Scott Stanchfield was tasked with optimizing memory usage in a Java application and found a way to shave a few bytes left in by an intern with a sense of humor ...


public class ValidationMessage

{
//internal members
string messageId;
string messageText;
string helpLink;
/* ... */
double cheeseburger;
char broiled;
long time;

//helper functions
/* ... */
}




What a whopper that is!

Alex Papadimoulis:

The following variable names (submitted by A and O, respectively) are best enjoyed with a maturity age of fourteen years or less ...


float CumRate;  // Cumulative pass rate


...

string ass = Request.Form["associated_skill_"+selId];
if (ass.IndexOf(",") > -1)
{
ass = ass.Split(',')[0];
}
row.ID = int.Parse(ass)



This cracks me up!  ;)

Re: Another Friday Smorgasbord

2006-07-14 14:47 • by juvenile
81723 in reply to 81720
Anonymous:
juvenile:

I get the abbreviation with initials, but what else does puhse stand for?



Two syllables...pronounce it.



Man, I gotta start thinking with multiple syllables? It's Friday for God sakes!

Re: Another Friday Smorgasbord

2006-07-14 14:48 • by Dude
Alex Papadimoulis:


Scott Stanchfield was tasked with optimizing memory usage in a Java application and found a way to shave a few bytes left in by an intern with a sense of humor ...


public class ValidationMessage

{
//internal members
string messageId;
string messageText;
string helpLink;
/* ... */
double cheeseburger;
char broiled;
long time;

//helper functions
/* ... */
}




I guess we know where that guy is going to be working

Re: Another Friday Smorgasbord

2006-07-14 14:50 • by pete23
81725 in reply to 81699
the real WTF then is that they're not using a debugger with conditional f-breakpoints! come on, this technology has been in debuggers for at least the last ten years...

Re: Another Friday Smorgasbord

2006-07-14 14:52 • by BradC
Alex Papadimoulis:
And while we're picking on the VS Tools for Office, following is the code required to call Excel's Dialog Show from C# ...

if(xlApp.Dialogs[Excel.XlBuiltInDialog.xlDialogOpen].Show(sTextName,

Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing) == true) { ... }



Ah, score one for VB.Net, which supports optional arguments.


Take that, C# !!!

Re: Another Friday Smorgasbord

2006-07-14 14:53 • by pete23
81728 in reply to 81709
John Bigboote:
Ytram:


One of my favorite pieces of code that is similar to this is in the system at my company.  Written by yours truly, it looks a little something like this:

Assessment ass = new Assessment(...);
...
if(ass.Dirty)
{
    ...
}



I like to come up with creative sub-classes of exception so that I can write things like

catch(BranchOperationRequiredException bare)

and

catch(DuplicateOperationPreventedException dope)


i've seen the MetaData Mapping Application and the Load Save Delete module... a blast when combined.

Re: Another Friday Smorgasbord

2006-07-14 14:56 • by John Bigboote
I've come up with a sweet alternative to privatizing the constructor in a class with static object creation methods.

public class Monkey
{
    public Monkey()
    {
       PrivateObjectOperationPreventedException poope = new
PrivateObjectOperationPreventedException("akk akk akk");
       throw poope;
    }
}

Re: Another Friday Smorgasbord

2006-07-14 14:59 • by John Bigboote
81730 in reply to 81728
Anonymous:


i've seen the MetaData Mapping Application and the Load Save Delete module... a blast when combined.


Mix it up with the Public Collaborative Presentation layer, and you will give the user the belief that they can do just about anything.

Re: Another Friday Smorgasbord

2006-07-14 14:59 • by Jonathan Pryor
81731 in reply to 81714
On a vague tangent, I really wish I could find a compiler/preprocessor
that supported named arguments in C,  C++, C#, or Java. Everytime I
touch win32 code after a month or two elsewhere I come back and end up
clueless as to what arguments are doing, especially surrounded by a
random number of NULLs.





This is actually fairly easy to do within the C++, C#, and Java languages.  Stroustrup gave an example in The Design and Evolution of C++, showing that named arguments weren't necessary.



The solution is to introduce a new type with methods which return itself.  For C++:

class window_args {

public:

    window_args& color (Color c) {/* ... */ return *this;}

    window_args& border (Border b) {/* ... */ return *this;}

    window_args& title (const std::string& s) {/* ... */ return *this;}

    /* ... */

};

void* CreateWindow (window_args args);


Usage thus becomes:

void* p = CreateWindow (

    window_args().color (Color::Blue).title ("insert title here));


This pattern is readily extended to C# and Java.

Re: Another Friday Smorgasbord

2006-07-14 15:03 • by hehe
81733 in reply to 81705
cconroy:
Alex Papadimoulis:
  ass = ass.Split(',')[0];






Best. Line of code. Ever.





dont forget this one:
assOLE = chop($ass)

Re: Another Friday Smorgasbord

2006-07-14 15:17 • by Jonathan Allen
81734 in reply to 81700

>if(xlApp.Dialogs[Excel.XlBuiltInDialog.xlDialogOpen].Show(sTextName,
>  Type.Missing


> NOW do we understand why optional params are a bad idea?? Over f'ing load the method, people, I think even VB.NET can handle that. Suppose this was just a COM wrapper though...


Lets see, I can either have 2^30 overloads to account for all the cases or I can just make one function with optionals. I think I'll stick with optionals for awhile longer.


 

Re: Another Friday Smorgasbord

2006-07-14 15:39 • by Martin
81736 in reply to 81725

Anonymous:
the real WTF then is that they're not using a debugger with conditional f-breakpoints! come on, this technology has been in debuggers for at least the last ten years...


Alas, VS2005 cannot support conditional breakpoints in C# however!

Re: Another Friday Smorgasbord

2006-07-14 15:41 • by SadBugKiller
81737 in reply to 81725
3
Anonymous:
the real WTF then is that they're not using a debugger with conditional f-breakpoints! come on, this technology has been in debuggers for at least the last ten years...

Right, it's there and completely unusable - just set a conditional breakpoint somewhere to enjoy 10x decrease in performance. Unconditional breakpoint inside an if operator behaves much better (I'm talking about Visual Studio up to 2005, I haven't tried that one; and C++ code - I haven't touched C# for a long time but as far as I remember it was the same story)

Dummy1()-Dummy15()

2006-07-14 15:42 • by Sam

Mark came across the Dummy16() and Dummy17() methods in the Visual Studio Tools for Office SDK and wondered, what ever happened to Dummy1() through Dummy 15() ?


thats actually easy: in public API usually a few dummy() methods are put in to have room to add future API calls without changing object layout/size (vtables and stuff).


So Dummy1() to Dummy15() already got replaced with some real functions that had been added to the class.

Re: Another Friday Smorgasbord

2006-07-14 15:45 • by Adam
81739 in reply to 81718
juvenile:

Anonymous:
Anonymous:
John Bigboote:


I like to come up with creative sub-classes of exception so that I can write things like

catch(BranchOperationRequiredException bare)

and

catch(DuplicateOperationPreventedException dope)


or maybe:
catch(PriceUnitHolderSelectionException puhse)


That's real by the way :)


I get the abbreviation with initials, but what else does puhse stand for?



You don't get puhse? I guess if you don't understand what it is you never will. Oh well, more for me I guess.

Captcha: batman. A man that probably understands the meaning of puhse very well.

Re: Another Friday Smorgasbord

2006-07-14 15:46 • by smxlong
81740 in reply to 81701
"public class" is not valid C++. So it's neither valid Java nor C++. Hoax?

Re: Another Friday Smorgasbord

2006-07-14 15:46 • by SomeCoder
81741 in reply to 81700
Anonymous:

>if(xlApp.Dialogs[Excel.XlBuiltInDialog.xlDialogOpen].Show(sTextName,
>  Type.Missing


NOW do we understand why optional params are a bad idea?? Over f'ing load the method, people, I think even VB.NET can handle that. Suppose this was just a COM wrapper though...



There's no problem with optional params.  The real WTF lies in the fact that C# can't freaking handle optional params.


GoatCheez:


..... assuming that string was defined as a type.... otherwise all fingers point to C# ;-)



A bit of a nitpick, but string is defined as a type if you're using the STL.


captcha: chocobot - Should be chocobo :)

Re: Another Friday Smorgasbord

2006-07-14 15:47 • by Martin
81742 in reply to 81740

smxlong:
"public class" is not valid C++. So it's neither valid Java nor C++. Hoax?


It is perfectly valid c# though.

Re: Another Friday Smorgasbord

2006-07-14 15:59 • by Me
81744 in reply to 81720
Anonymous:
juvenile:

I get the abbreviation with initials, but what else does puhse stand for?



Two syllables...pronounce it.



OK, let's see;
Two syllables: puh-se
  • puh, as in Winne the Pooh?
  • se, as in Standard Edition?
Pronounced: [pu:se]

Not funny at all.

Re: Another Friday Smorgasbord

2006-07-14 16:07 • by juvenile
81745 in reply to 81744
Anonymous:
Anonymous:
juvenile:

I get the abbreviation with initials, but what else does puhse stand for?



Two syllables...pronounce it.



OK, let's see;
Two syllables: puh-se


  • puh, as in Winne the Pooh?

  • se, as in Standard Edition?

Pronounced: [pu:se]

Not funny at all.


When I first read it, I read it aloud with a long 'u', silent 'h', soft 's' and silent 'e' - sorta like 'piews' - had no clue - been a long f*g week - tgif! Gotta go home to wife/kids and not get me some.


 

Re: Another Friday Smorgasbord

2006-07-14 16:11 • by juvenile
81746 in reply to 81745

A better name might be:


catch (ProblemUndoingShortSaleYesterday pussy)

Re: Another Friday Smorgasbord

2006-07-14 16:17 • by juvenile
81748 in reply to 81746

The worst (?) one I ever saw was from this person who was extremely intelligent, who created a project acronym that, for obvious reasons, never got used:


Common Library Internals Tying Original Real Income Server

Re: Another Friday Smorgasbord

2006-07-14 16:19 • by John Bigboote
81749 in reply to 81746
juvenile:

A better name might be:


catch (ProblemUndoingShortSaleYesterday pussy)



If I caught more of that type of exception in college, I might not be a programmer today. It's a pretty rare scenario for most coders.

Re: Another Friday Smorgasbord

2006-07-14 16:20 • by Philbert Desanex
81750 in reply to 81746
juvenile:

A better name might be:


catch (ProblemUndoingShortSaleYesterday pussy)



Beautifully unambiguous.


When asked for a project estimate, I tell folks that I use the Millenial Year Application Software System to pull my numbers from.

« PrevPage 1 | Page 2 | Page 3Next »

Add Comment