If past CodeSOD articles are any indication, it would seem that "certain" developers have a very difficult time wrapping their minds around spaces and spacing.

How do you replace double spaces? What about triple spaces?? Or quadruple??? Clearly, these were questions asked by the coders of today's two specimens. And obviously, they found their answers.

Damian came across this snippet while reviewing code; obviously, the author didn't think six blank spaces were possible.

 /**
  * This method checks to see if any of the input fields are blank spaces.
  * Creation date: (1/3/01 3:12:19 PM)
  * 
  * @return boolean
  * @param param
  *            java.lang.String
  */
 public boolean isBlank(String str) {
  if (str.equals("") || str.equals(" ") || str.equals("  ")
    || str.equals("   ") || str.equals("    ")
    || str.equals("     "))
   return true;
  else
   return false;
 }// end

 

The other snippet is from Hervie Adkisson, who still can't quite figure out the logic behind it.

' Replaces the characters set in strUnwanted as spaces
Public Function RemoveCharacters(ByRef strText As String) As String
    Dim spaces10 As String = "          "
    Dim spaces3 As String = "   "
    Dim spaces2 As String = "  "
    Dim spaces1 As String = " "

    RemoveCharacters = Replace(Replace(Replace(Replace(Replace(strText, spaces10, spaces1), _
    spaces10, spaces1), spaces3, spaces1), spaces2, spaces1), spaces2, spaces1)
End Function
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!