Looks like a cross between Ellen Degeneres and a workout video still
from the 80's. Maybe it's trying to tell us that J# is really
lame?
Charles_Nadolski
@Charles_Nadolski
Best posts made by Charles_Nadolski
-
RE: What's wrong with this picture?
Latest posts made by Charles_Nadolski
-
Bad code as art form
(I submitted this as a Code SOD but I post it here in case it isn't published)
An ex-coworker of ours took the simplest of tasks and gave them a whole new level of abstraction. Some would call him a terrible programmer, I call him an artistic genius:
private Decimal GetNumStatsPerPage()
{
int factor = 0;
if (this.demoGroupLimit % this.stats.Length == 0) //if stats per page is a multiple of num demos
return (Decimal)this.demoGroupLimit;
else //if not a multiple, return smaller value until it is a multiple of num demos to fit stats per demo per page
{
for( int idx = 1 ; idx < this.demoGroupLimit; idx++ )
{
if ((this.demoGroupLimit - idx) % this.stats.Length == 0)
{
factor = idx;
break;
}
else
continue;
}
return (Decimal)this.demoGroupLimit - factor;
}
}Note the use of else-continue, a common paradigm among his masterpieces, and the blatant use of Decimal instead of int is so post-modern. Here is the "correct", but totally unaesthetically pleasing version version of the code:
private int GetNumStatsPerPage()
{
return this.demoGroupLimit - this.demoGroupLimit % this.stats.Length;
} -
In Code We Trust
(this was submitted to the main site, but in case it's not published, it's here for your amusement)
A gem from a colleague who quit recently, and he is now working for the state (your tax dollars at work). Some funny stuff here. It seems subconsciously he was telling himself something, that perhaps his code was not to be trusted, as he checks many things twice. He uses GetDataByPrint, which returns all rows where "Print=True". Just in case, he then checks for "Print=True". He also checks if one table contains a key, then double-checks if the same table does NOT have a key.... even though the avlBook and the invBook tables have a one-to-one relationship: the keys are always the same!
One of our house rules is that we use strongly-typed datasets using Microsoft's dataset designer in Visual Studio. For some reason, he insisted on manipulating rows and tables the Hard Way (notice the use of the object named "key"). ComponentOne also has some handy functions for looking up data in a grid that would have made his life easier. Maybe he just didn't trust anybody else's code either.
private void LoadListBoxBooks()
{
InvDBDS.invBookDataTable dtData = m_initechApp.InvDBDS.invBookAdapter.GetSortedData();
InvDBDS.avlBookDataTable printBkTbl = m_initechApp.InvDBDS.avlBookAdapter.GetDataByPrint(true);
bookGrid.Initialize(dtData, "Initech Enterprise Manager");
for (int idx = 1; idx < bookGrid.Rows.Count; idx++)
{
object key = bookGrid[idx, 0];
key = (object)(( InvDBDS.invBookRow[])dtData.Select(string.Format( "Description = '{0}'", key.ToString())))[0].BookID;
if (printBkTbl.Rows.Contains(key) && (bool)printBkTbl.Rows.Find(key)["Print"] == true )
{
bookGrid.Rows[idx].Selected = true;
if (!printBkTbl.Rows.Contains(key) && idx == 1) //do not add first default selected row if not in settings
continue;
else
this.actBooks.Add((int)key);
}
}
}
How should the non-paranoid code have looked?
private void LoadListBoxBooks()
{
bookGrid.Initialize(m_initechApp.InvDBDS.invBookAdapter.GetSortedData(), "Initech Enterprise Manager");
int nRow = bookGrid.Rows.Fixed;
foreach (InvDBDS.avlBookRow rowAvlBook in m_initechApp.InvDBDS.avlBookAdapter.GetDataByPrint(true))
{
//Match a datarow in the table to a datarow in the grid
nRow = bookGrid.FindRow(rowAvlBook.invBookRow.Description, nRow, bookGrid.Cols["Description"].SafeIndex, false);
bookGrid.Rows[nRow].Selected = true;
this.actBooks.Add(rowAvlBook.BookID);
}
}
PS: some variable names and strings have been changed to protect the innocentPPS: this ex-colleague is a goldmine for WTF's. I'll post more when I have time.
-
RE: Teaching IT in a modern world.
@strongarm said:
Someone needs to slap this teacher.
This guy sounds like the prof I had back in a business systems
design...he showed up to class drunk everyday and would make the
students teach the class...until enough of us filed complaints and
got him booted.
I had a French Literature professor who would not only do that, but
would also not show up and not tell anybody, would dismiss class 30
minutes early sometimes, not grade anything (if any sensical
assignments were ever given), only had a syllabus that went 8 weeks
into the semester, and made sexual advances toward one of the students
outside of class.
When we delivered a petition to the head of the French department, he
said (in English) "well I'm finally glad we got the ball rolling here".
-
RE: User WTF
@cm5400 said:
@Charles Nadolski said:
Oh and the user wants me to replicate full excel functionality in my software. Reinventing the wheel was never this fun!Isn't this illegal to do with MS developer tools? I remember something stating that you can not use their tools to develop a program that simulates one of theirs? I could be wrong, I need to read that oh so fancy EULA again.[:)]
Actually, you can embed office automation tools into a visual studio application. The pre-alpa version of our product allowed you to import and edit excel spreadsheets directly this way. The catch it you have to have Excel installed on your machine for it to work. Unfortunately, it would take a half-minute every single time you changed something in the spreadsheet :-/
-
RE: User WTF
@Manni said:
My favorite is where they had a list of values
in a drop-down list, and they wanted to prevent the user from
submitting the form is one particular value was selected, as that value
was not allowed. I suggested that I just remove it from the list. Nope,
that value MUST stay in the list, and the user MUST NOT be allowed
to select it.
I feel you for ya man. I experienced the EXACT SAME SITUATION
YESTERDAY. We have this custom roguewave grid control.
What's spiffy about it is that you can embed a combobox into a grid
cell. Depending on certain situations, the combobox will remove
items that are unselectable, which was a total PTA, since you can only
indirectly edit the combobox. Now the user wants me to put the
missing items back in, but grey them out. I tried explaining that
this was extremely difficult (besides being completely pointless) to
do. So he said that I should just put an asterisk instead.
Okay... so the ones with the asterisk are available or
unavailable? And nothing happens if you pick the one with the
asterisk even though you select it? This is supposed to be easier
and less confusing HOW?
Also got a complaint about screen real estate. The original program was
for windows 3.1 (that's still in use), and used about 20 cascading
screens. I manage to get the GUI down to a single screen.
Only prob is that the user ran at 800x600. So we increase it to
1024x768 after a large struggle and a monitor upgrade. Okay, now
the user is going crazy because he/she has to scroll to see the rest of
the data. People are never happy. Also, the user wanted to
display multiple data in multiple places. Also the user wanted me
to unhide columns that I had hidden to save screen real estate (even
though the column data would not be used).
Oh and the user wants me to replicate full excel functionality in my software. Reinventing the wheel was never this fun!
-
RE: What's wrong with this picture?
Looks like a cross between Ellen Degeneres and a workout video still
from the 80's. Maybe it's trying to tell us that J# is really
lame?