Mark Baker and Aaron Jenkins had one thing in common: they were both in the midst of a transition at Initech Global. It was Aaron's last day on the job and Mark's very first, and Aaron was tasked with helping Mark get acquainted with the applications, servers, and whatever else a new employee might need.

Of course, seeing that it was Aaron's last day, Mark's "brain dump" consisted of a single item: how to unlock the front door and disarm the alarm system. "So let's see," Aaron explained, "if you're the first one in, just put this here key into this here lock and give it a turn. Got it? Then punch 8863 on the alarm panel. Got it?"

Aaron's only other bit of fleeting advice was "everything else is checked in, you'll find it." And find it he did. One of the first pieces of code that Mark found was this:

NumPages = IntDivide(ds.Tables(0).Rows.Count, 56) + 1

Curious as to why a special function was needed to divide integers in .NET, Mark took a look at IntDivide().

'------------------------------------------------------------------
'-- NAME:                   IntDivide
'-- PURPOSE:                Returns the integer division of one 
'--                         number by another.
'-- IN PARAMETERS:          Numerator, denominator.
'-- OUT PARAMETERS:         Result. 
'------------------------------------------------------------------
'-- REVISION HISTORY:
'-- 
'-- WHEN        WHO         WHAT
'-- 08/29/08    ????        Initial creation.
'------------------------------------------------------------------
Public Function IntDivide(ByVal Num As Integer, ByVal Denom As Integer) As Integer
  Dim Result As Integer = 0

  If Denom <> 0 Then
    Dim SQL As String = "SELECT (" & Num.ToString & "/" & Denom.ToString & ") AS Res"
      Dim ds As New DataSet
      
      If GetDataSet(SQL, ds) Then
        If ds.Tables(0).Rows.Count > 0 Then
          Result = ds.Tables(0).Rows(0).Item(0)
        End If
      End If
    End If

    Return Result
End Function

Yes, Aaron made a call to SQL Server, and filled a DataSet just divide two integers! I guess Math.Floor(Num / Denom) was too easy.

As for Aaron's "how to disarm the alarm" instructions? He ended up using them the following week, and the police subsequently showed up. But at least he did learn how to use a key.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!