"This code was left by the Senior Software Consultant," Michael Wheeler writes, "I'm not sure if it's insurance against 'Return' not returning... or a comment that explained why the line of code was left in."

Public Shared Function GetItemFromValue(ByVal ddlControl As DropDownList) As Integer
    Dim i As Integer
    If ddlControl.Items.Count > 0 Then
        For i = 0 To ddlControl.Items.Count - 1
            If ddlControl.Items(i).Selected() Then
                Return i
                Exit For     'leaving this here cause we're in a rush
            End If
        Next
    End If
End Function

 

"We're aparantly pretty serious about 'properly' handling exceptions," writes Rami, "very, very serious."

public bool Receive( string FilePath )
{
    try
    {
        return true;
    }
    catch( Exception e )
    {
        ExceptionManager.Publish( e, Priorities.High );
        return false;
    }
}

 

"A nice example of ahead planning," Robert writes, "just in case the Earth's mass dramatically changes overnight, we are prepared for a fast, system-wide adjustment."

Public Function Newton()
    Newton = 9.81
End Function

 

"Some developers use JavaScript for validation, others use server-side code," Rio writes, "we, on the other hand, seem to use comments. It doesn't really validate anything, but hey, it's good."

If fromDate < toDate Then
   'it's good.
Else
   'it's not good.
End If

 

"I was going through some obscure code from the developers before me, and something caught my eye," Philippe wrote. "It was a class whose task was to transform data, and this is how it was instantiated."

Transformer optimusPrime = new Transformer();

 

"Gee thanks," Tobias N. Sasse writes, "that's helpful!"

public long getLength() {
  return 1000000;  // no clue
}

 

"I tried to put some italic tags around a bit of text today," writes Derek, "but somehow, it emboldened my text. I did some digging, and I found that our front-end developer has this in our CSS stylesheet."

i { color: #000; font-weight: bold; font-style: normal; }

 

"I guess the comment header is right," Brian M writes, "no po box for you!"

//*******************
//**
//** Function   - POBox
//** Purpose    - no po box
//**
//*******************
 
function POBox(eobj, eid) 
{

	return (true);
}

 

"So that's how you DeUnicode stuff" David Nguyen wrote, "and here I thought it involved a bit more than removing an italics tag."

function DeUnicode($_input){
  //added to strip out italics tag <i> from name
  $_input = str_replace('<i>', '', $_input);
  $_input = str_replace('</i>', '', $_input);
  return $_input;
}

 

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