| « The Standard Way | Introducing Bad Code Offsets » |
"I was put on a new Microsoft Access project recently," Stuart A writes, "and I've slowly been finding my way around the system as the need arises (read: as bugs are reported). As my eyes drifted over the numerous modules, one stopped me in my tracks. It was a module named 'modHmm'. I guessed the programmer was in a ponderous mood?. So naturally, I had a look inside..."
Option Compare Database Option Explicit Global t1qq Global t2qq Global t3qq ...
"The file started off as usual," Stuart continued, "Globally declared variables without types that were poorly named and to be used who-knows-where. It was pretty standard stuff for our modules. So I continued looking..."
Public Sub UpdateThing()
Dim adoRst As New ADODB.Recordset
Dim comRate As Double
adoRst.Open _
"SELECT * FROM view91 WHERE Transaction_GLAccount_Code = '12055'", _
Application.CurrentProject.Connection, adOpenStatic, adLockOptimistic, adCmdText
Do Until adoRst.EOF
adoRst!Transaction_GLAccount_Code = "12056"
adoRst.Update
adoRst.MoveNext
Loop
adoRst.Close
End Sub
"Okay. So the function names were turning out to be as descriptive as the module name. Fine. But then I saw..."
Public Sub dude()
Call sbWriteGLTransaction("2003CD1182", _
"Cheque Sent Bank", Fdate("2002-07-10"), -4097.47, _
"Dealer: Diner's Club", glClass.Company_Code, "12025")
Call sbWriteGLTransaction("2003CD1182", _
"Cheque Sent Creditor", Fdate("2002-07-10"), 4097.47, _
"Dealer: Diner's Club", glClass.Company_Code, glClass.GetGLCode("CR"))
End Sub
"Dude?!" Stuart wrote, "not only Dude, but that but Public Dude?! What are we doing?? My eyes continued down the page..."
Public Sub hhhhhfjhskjfds()
Dim rst As ADODB.Recordset
Set rst = useADO("View57", 2, , , 1)
Do Until rst.EOF
Call ocClass.setDateCompleteOnConsignmentItem( _
Format(rst!StockMovement_Date, "dd/mm/yyyy"), _
"Stock Written Off", , _
rst!OnConsignmentItem_OnConsignment_ID, _
rst!StockMovement_StockNumber)
rst.MoveNext
Loop
End Sub
"I'm stunned!" Stuart added, "the rest of the functions were similarily named: jklsadjflksd(), ggggg(), ddd(), etc."
"Hmmmmm, indeed."
|
Poorly named? Well, that's just, like, your opinion, man.
|
|
It makes me think of some code I worked on many moons ago (in fact it was 1990-1993).
It was an embedded system with a proprietary multithreading system. The guy who originally wrote it wanted to celebrate buying a new car, so the central control variable of the scheduler was "golf_gti". Sad to say, neither I nor the guy I worked with cared enough to change it. Nor the joke buried in the gas compressibility calculations. The equations themselves feature Greek letters pi and tau, but because of the common pronunciation of the latter as "tor" and some time adapting the code from a dialect of BASIC, the C variable holding the pi value acquired an e to become pie, and tau, misspelled tor, was rejected by the BASIC and became, in C, apple. double apple, pie; Fist Of Death online, armed and ready. |
| « The Standard Way | Introducing Bad Code Offsets » |