|
0. Find the person who write this code.
1. Work out were they live.
2. Break into the home.
3. LEave a severed head in his head.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
It looks surprisingly similar to the code you posted two days ago under the heading "Where's Waldo".
|
|
|
|
|
Yes, only this one was even a bigger horror especially since it only has one line of code that does anything & it's not even something that could raise an error. It's positively lovely.
|
|
|
|
|
I've seen this error rig code before. Sage Software has a utility in their MAS500 SDK that you can run to add error handle to all functions and subs that generates code very similar to this. There is no way anyone is hand writing that much error handling for "Cancel = True".
|
|
|
|
|
Yeah, I think this was a plug in which added this mess to all new functions/subs. They've since stopped using it, but it's still as one fugly mug when you see it, especially in something like this. Were I given a free reign, I'd be all over the my delete button right now.
|
|
|
|
|
This is a horror indeed, but one thing puzzles me:
Wes Jones wrote:
On Error GoTo aLabel_AfterLabelEdit_VBRigErr
Does VB support "long jumps" or sth? I don't see a aLabel_AfterLabelEdit_VBRigErr anywhere...
Greetings - Jacek
|
|
|
|
|
not that I know of.. it just doesn't care if the goto label there apparently.
|
|
|
|
|
This code looks like it was generated by an automated tool for injecting error handling code.
|
|
|
|
|
yes, it was. isn't it beautiful?
|
|
|
|
|
|
Here's one I know we've all seen, but it always give me a chuckle:
if ((from i in dc.PRODUCTIONs
where i.ACTIVE == true
select i.WOID).Contains(getSysId(woid)) == false)
If you think this is bad, you should see how the actual software runs! Ever since I started working for this company, I've had to completely strip and rebuild all the code most of it only half works. I'll post more horrors as I find them. Happy coding!
-- Steven
|
|
|
|
|
|
I'm not too familiar with linq yet, what's wrong with this one?
Wout
|
|
|
|
|
Everything is between the if ( )
|
|
|
|
|
Uuuh...
So what's the bug?
Wout
|
|
|
|
|
It's not a bug, but the code is very difficult to understand, even for experienced programmers. The guy should have used variables to store intermediate results.
|
|
|
|
|
Aaaah, I thought it was my unfamiliarity with linq, geez!
Wout
|
|
|
|
|
I swear I'm not making this up:
Private Sub aControl_DblClick()
'+++ VB/Rig Begin Push +++
Const VBRIG_PROC_ID_STRING = "+aControl_DblClick"
Dim VBRigErr As Long, VBRigErrMsg As String
If VBRig.Trap_TrapsEnabled Then
On Error GoTo aControl_DblClick_VBRigErr
End If
Call VBRig_Error(VBRIG_PUSH_PROC_STACK, 0, "", VBRIG_MODULE_ID_STRING, VBRIG_PROC_ID_STRING)
'+++ VB/Rig End +++
If someIndicatorVariable < 1 Then
'+++ VB/Rig Begin Pop +++
Call VBRig_Error(VBRIG_POP_PROC_STACK, 0, "", VBRIG_MODULE_ID_STRING, VBRIG_PROC_ID_STRING)
'+++ VB/Rig End +++
Exit Sub
End If
Call LaunchAnEXE("EXENAME", "params")
Unload Me
'+++ VB/Rig Begin Pop +++
Call VBRig_Error(VBRIG_POP_PROC_STACK, 0, "", VBRIG_MODULE_ID_STRING, VBRIG_PROC_ID_STRING)
Exit Sub
'=========================
aControl_DblClick_VBRigErr:
'=========================
VBRigErr = Err
VBRigErrMsg = Error$
Call VBRig_Error(VBRIG_SHOWLOG_ERROR, VBRigErr, VBRigErrMsg, VBRIG_MODULE_ID_STRING, VBRIG_PROC_ID_STRING)
Call VBRig_Error(VBRIG_POP_PROC_STACK, 0, "", VBRIG_MODULE_ID_STRING, VBRIG_PROC_ID_STRING)
Exit Sub
'+++ VB/Rig End +++
End Sub
|
|
|
|
|
VBRig_Error(VBRIG_POP_HOLY_CRAP, 0, "", VBRIG_MODULE_ID_STRING, VBRIG_PROC_ID_STRING)
Exit Life
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
A, Looks like old VB3 code to me.
B, Looks like a quick and dirty throw-away test harness of some sort.
How many times have we seen those turn into production code?
|
|
|
|
|
Here's one that's created in Informix 4GL (which is a horror in itself) on how to validate a from-and-to range to make sure it has no overlaps in the DB:
FUNCTION verify_location()
DECLARE c_det_cur CURSOR FOR
SELECT frerc.from_loc_id, frerc.to_loc_id
FROM frerc
WHERE frerc.dc_id = m_i_frerc_rec.dc_id
AND frerc.whse_id = m_i_frerc_rec.whse_id
# check if select worked correctly
IF SQLCA.SQLCODE <> 0
THEN
#...
RETURN TRUE, 0
END IF
OPEN c_det_cur
IF SQLCA.SQLCODE <> 0
THEN
#...
RETURN TRUE, 0
END IF
FETCH c_det_cur INTO m_from_loc, m_to_loc
IF m_modify = 0 AND m_i_frerc_rec.from_loc_id >= m_from_loc
AND m_i_frerc_rec.from_loc_id <= m_to_loc
THEN
CALL sh_err_msg("S2096")
LET m_from = 1
LET m_modify = 1
END IF
IF m_modify = 0 AND m_i_frerc_rec.to_loc_id >= m_from_loc
AND m_i_frerc_rec.to_loc_id <= m_to_loc
THEN
CALL sh_err_msg("S2097")
LET m_from = 1
LET m_modify = 1
END IF
IF m_from_loc >= m_i_frerc_rec.from_loc_id
AND m_from_loc <= m_i_frerc_rec.to_loc_id
THEN
CALL sh_err_msg("S2097")
LET m_from = 1
LET m_modify = 1
END IF
IF m_modify = 0 AND m_to_loc >= m_i_frerc_rec.from_loc_id
AND m_to_loc <= m_i_frerc_rec.to_loc_id
THEN
CALL sh_err_msg("S2096")
LET m_to = 1
END IF
IF m_to = 0 AND
m_from = 0
THEN
WHILE SQLCA.SQLCODE = 0
FETCH c_det_cur INTO m_from_loc, m_to_loc
IF m_i_frerc_rec.from_loc_id >= m_from_loc
AND m_i_frerc_rec.from_loc_id <= m_to_loc
THEN
CALL sh_err_msg("S2096")
LET m_from = 1
EXIT WHILE
END IF
IF m_i_frerc_rec.to_loc_id >= m_from_loc
AND m_i_frerc_rec.to_loc_id <= m_to_loc
THEN
CALL sh_err_msg("S2097")
LET m_from = 1
EXIT WHILE
END IF
IF m_from_loc >= m_i_frerc_rec.from_loc_id
AND m_from_loc <= m_i_frerc_rec.to_loc_id
THEN
CALL sh_err_msg("S2097")
LET m_to = 1
EXIT WHILE
END IF
IF m_to_loc >= m_i_frerc_rec.from_loc_id
AND m_to_loc <= m_i_frerc_rec.to_loc_id
THEN
CALL sh_err_msg("S2096")
LET m_from = 1
EXIT WHILE
END IF
END WHILE
END IF
LET m_modify = 0
END FUNCTION
|
|
|
|
|
Am I missing something? Why would you do this?
protected int GetTransactionLength(string transaction)
{
return transaction.Length;
}
is this not less code
transaction.Length
than this?
GetTransactionLength(transaction)
This may seem small, but it's just pushed me over the edge. It comes from a program that should be simple and beautiful but it full if this sort of stuff, it’s driving me nutts!
|
|
|
|
|
Depends - was the transaction.Length private? If so, then perhaps someone hasn't got up to properties in the course yet...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Nope, I have just deleted this method and used the transaction.length and it compiled fine. I could understand it if you want to manipulate the length, so I checked the history of the file in source control to see if it ever did and it's always just returned the length.
|
|
|
|
|
So not only is it silly code, but silly code with public fields? Deep joy...
Is the original coder still there, or have they decided to continue the course instead?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|