|
Wow, this guy knows nothing, look at all those magic numbers, how are you meant to know what they mean?
Const Number1 As Int32 = 0
Const Number2 As Int32 = 1
Const Number3 As Int32 = 13
Const Number4 As Int32 = 14
Const Number5 As Int32 = 10977
Const Number6 As Int32 = 10978
Const Number7 As Int32 = 10979
Const Number8 As Int32 = 10980
Const Number9 As Int32 = 10981
Const Number10 As Int32 = 10982
Const Number11 As Int32 = 10983
Const Number12 As Int32 = 10984
Const Number13 As Int32 = 10985
Const Number14 As Int32 = 10986
Const Number15 As Int32 = 10987
Const Number16 As Int32 = 10988
If Something() Then
chkLogLateShiftEnd.Caption = GetCaptionText(Number16, chkLogLateShiftEnd.Caption)
chkKeepOrigRadioName.Caption = GetCaptionText(Number8, chkKeepOrigRadioName.Caption)
Frame9.Caption = GetCaptionText(Number15, Frame9.Caption)
Frame12.Caption = GetCaptionText(Number11, Frame12.Caption)
frapnl10(Number1).Caption = GetCaptionText(Number7, frapnl10(Number1).Caption)
Label13.Caption = GetCaptionText(Number12, Label13.Caption)
Label14.Caption = GetCaptionText(Number14, Label14.Caption)
Label5.Caption = GetCaptionText(Number13, Label5.Caption)
lblpnl03(Number4).Caption = GetCaptionText(Number9, lblpnl03(Number4).Caption)
lblpnl03(Number3).Caption = GetCaptionText(Number10, lblpnl03(Number3).Caption)
lblpnl10(Number2).Caption = GetCaptionText(Number5, lblpnl10(Number2).Caption)
lblpnl10(Number1).Caption = GetCaptionText(Number6, lblpnl10(Number1).Caption)
End If
FTFY (Yes, it is a slow day at work)
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
and they say it's hard to improve upon perfection...
|
|
|
|
|
looks like VB reverse engineered code or generated using some tool
|
|
|
|
|
I used to work with a framework that lived off of that. Piles of magic numbers, created by a mechanical engineer of course.
Worked well enough so long as you had the right spreadsheets printed out and wallpapered your cube with them, I assume you have no such spread sheets.
|
|
|
|
|
Didn't they give you the secret decoder ring?
|
|
|
|
|
It looks like the coder had asked "how to storr datas inside from classes plz help its urgent" on some forum but nobody answered him, so he/she put app data in invisible areas of caption texts. If it is true then try
lblpnl10(0).AutoSize = True
Greetings - Jacek
|
|
|
|
|
I think he may have worked for us.
But I must say that he seems to have improved with time.
|
|
|
|
|
We had a contract programmer do some work for us recently. Alas, he was hired by the Pointy Haired One, so this month I get to go over his work and correct errors. Among the steaming pile, I found this nugget:
RunTSMenuItem.Enabled = CBool(IIf(MyUser.HasPermission(Permission.Admin), True, False))
When a user logs into the application, an instance of MyUser is created with all of the user's permissions (among other data.) HasPermission(Permission.whatever) will return true if the user has the requested permission and false otherwise. The above code activates a menu item on a form if the user is an administrator, otherwise the menu item is inactive.
Unfortunately, this guy was overly fond of IIf and used it every opportunity he could, whether needed or not.
|
|
|
|
|
That's a mighty nice turd you found there
|
|
|
|
|
I'm converting an MS Access app to C# & SQL Server. Here's part of an Access query I just came across:
IIf(TX.TX_TYPE="R",
IIf(TX.TX_MOSTYPE="P",
IIf(TX.TX_DEST_STATUS="A","PO Receipt",
IIf(TX.TX_DEST_STATUS="U","PO Receipt Hold","Other")),
IIf(TX.TX_DEST_STATUS="A","WIP Receipt",
IIf(TX.TX_DEST_STATUS="U","WIP Hold","Other"))),
IIf(TX.TX_TYPE="I",IIf(ISNULL(RTRIM(TX.TX_MOSJOB)) Or RTRIM(TX.TX_MOSJOB)="","Shipment Return","Reverse Issue"),
IIf(TX.TX_ORIGIN_STATUS=TX.TX_DEST_STATUS,"Loc Transfer",
IIf(TX.TX_ORIGIN="SCRAPPED","Reverse Scrap",
IIf(TX.TX_ORIGIN_STATUS="J","Count Adj Up",
IIf(TX.TX_ORIGIN_STATUS="D","PN Change To",
IIf(TX.TX_ORIGIN_STATUS="I","Reverse Unplanned Issue",
IIf(TX.TX_ORIGIN_STATUS="A" And TX.TX_DEST_STATUS="U","Hold",
IIf(TX.TX_ORIGIN_STATUS="U" And TX.TX_DEST_STATUS="A","Off Hold","Other"))))))))) AS [Transaction Type]
You'll notice that
TX.TX_DEST_STATUS="A" is being evaluated more than once.
Go figure
Everything makes sense in someone's mind
moved on Thursday, January 28, 2010 7:54 AM
|
|
|
|
|
I think step 1 is to delete it and then ask what the original intention was.
|
|
|
|
|
This is where you write a bank of unit tests, based on the input/output of this clause.
Then refactor ensuring all tests keep passing.
|
|
|
|
|
With a bit of formatting, it makes 'more' sense:
IIf
(TX.TX_TYPE="R",
IIf
(TX.TX_MOSTYPE="P",
IIf
(TX.TX_DEST_STATUS="A",
"PO Receipt",
IIf
(TX.TX_DEST_STATUS="U",
"PO Receipt Hold",
"Other"
)
),
IIf
(TX.TX_DEST_STATUS="A",
"WIP Receipt",
IIf
(TX.TX_DEST_STATUS="U",
"WIP Hold",
"Other"
)
)
),
IIf
(TX.TX_TYPE="I",
IIf
(ISNULL(RTRIM(TX.TX_MOSJOB)) Or RTRIM(TX.TX_MOSJOB)="",
"Shipment Return",
"Reverse Issue"
),
IIf
(TX.TX_ORIGIN_STATUS=TX.TX_DEST_STATUS,
"Loc Transfer",
IIf(TX.TX_ORIGIN="SCRAPPED",
"Reverse Scrap",
IIf
(TX.TX_ORIGIN_STATUS="J",
"Count Adj Up",
IIf
(TX.TX_ORIGIN_STATUS="D",
"PN Change To",
IIf
(TX.TX_ORIGIN_STATUS="I",
"Reverse Unplanned Issue",
IIf
(TX.TX_ORIGIN_STATUS="A" And TX.TX_DEST_STATUS="U",
"Hold",
IIf
(TX.TX_ORIGIN_STATUS="U" And TX.TX_DEST_STATUS="A",
"Off Hold",
"Other"
)
)
)
)
)
)
)
)
) AS [Transaction Type]
Granted, nesting like this just makes it impossible to read without a gratuitous use of formatting. The original query was just not very consistent in its usage of formatting it. The above was the best I could come up with to be able to read it effectively....
|
|
|
|
|
Btw, this looks more like a coding horror than 'wicked code'.
|
|
|
|
|
It's in the coding horrors section. Or was the topic moved later with all the replies? I didn't think it was possible to do so in codeproject.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
I was able to clean it up a bit more, although it took awhile.
CASE WHEN TX.TX_TYPE = 'R' AND TX.TX_MOSTYPE = 'P' AND TX.TX_DEST_STATUS = 'A' THEN 'PO Receipt'
WHEN TX.TX_TYPE = 'R' AND TX.TX_MOSTYPE = 'P' AND TX.TX_DEST_STATUS = 'U' THEN 'PO Receipt Hold'
WHEN TX.TX_TYPE = 'R' AND TX.TX_MOSTYPE = 'P' THEN 'Other'
WHEN TX.TX_TYPE = 'R' AND TX.TX_DEST_STATUS = 'A' THEN 'WIP Receipt'
WHEN TX.TX_TYPE = 'R' AND TX.TX_DEST_STATUS = 'U' THEN 'WIP Hold'
WHEN TX.TX_TYPE = 'R' THEN 'Other'
WHEN TX.TX_TYPE = 'I' AND ISNULL(RTRIM(TX.TX_MOSJOB),'') = '' THEN 'Shipment Return'
WHEN TX.TX_TYPE = 'I' THEN 'Reverse Issue'
WHEN TX.TX_ORIGIN_STATUS = TX.TX_DEST_STATUS THEN 'Loc Transfer'
WHEN TX.TX_ORIGIN = 'SCRAPPED' THEN 'Reverse Scrap'
WHEN TX.TX_ORIGIN_STATUS = 'J' THEN 'Count Adj Up'
WHEN TX.TX_ORIGIN_STATUS = 'D' THEN 'PN Change To'
WHEN TX.TX_ORIGIN_STATUS = 'I' THEN 'Reverse Unplanned Issue'
WHEN TX.TX_ORIGIN_STATUS = 'A' AND TX.TX_DEST_STATUS = 'U' THEN 'Hold'
WHEN TX.TX_ORIGIN_STATUS = 'U' AND TX.TX_DEST_STATUS = 'A' THEN 'Off Hold' ELSE 'Other'
END AS Transaction_Type
Everything makes sense in someone's mind
|
|
|
|
|
Nice to see people with some extra time on their hands
Learning without thought is labor lost; thought without learning is perilous. (Confucius)
|
|
|
|
|
It looks like Linq, pre-Linq.
Marc
|
|
|
|
|
I've seen Garbage like this before, it usually happens when engineers pretend to be programmers...
I laugh at inappropriate times
|
|
|
|
|
As you wrote: Everything makes sense in someone's mind
-muneeb
A thing of beauty is the joy forever.
|
|
|
|
|
Looks to me like a repeated event of technically challenged boss entering the room of a stressed halfwit programmer shouting: We need to add this NOW!
|
|
|
|
|
Holy sh*t...thats just horrific man. as long as I don't encounter that ever!
|
|
|
|
|
This dude is clearly a Lisp-genius, stuck with the wrong programming languge. What a pity!
........................
Life is too shor
|
|
|
|
|
I think he meant to make a Ladder; Only that it's lying on the wrong wall
Wamuti: Any man can be an island, but islands to need water around them!
Edmund Burke: No one could make a greater mistake than he who did nothing because he could do only a little.
|
|
|
|
|