Click here to Skip to main content
15,443,981 members

The Weird and The Wonderful


The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

GeneralRe: Ah, VB ... Pin
jgrogan29-Sep-11 20:52
Memberjgrogan29-Sep-11 20:52 
GeneralRe: Ah, VB ... Pin
zenstain30-Sep-11 3:47
professionalzenstain30-Sep-11 3:47 
General21,662 Pin
AspDotNetDev23-Sep-11 9:02
protectorAspDotNetDev23-Sep-11 9:02 
GeneralRe: 21,662 Pin
StM0n23-Sep-11 11:09
MemberStM0n23-Sep-11 11:09 
JokeRe: 21,662 Pin
Sander Rossel24-Sep-11 10:37
professionalSander Rossel24-Sep-11 10:37 
JokeRe: 21,662 Pin
AspDotNetDev24-Sep-11 11:00
protectorAspDotNetDev24-Sep-11 11:00 
GeneralRe: 21,662 Pin
Sander Rossel24-Sep-11 11:40
professionalSander Rossel24-Sep-11 11:40 
GeneralRe: 21,662 Pin
AspDotNetDev24-Sep-11 12:22
protectorAspDotNetDev24-Sep-11 12:22 
Ouch. I use lots of white space, but not that much. I actually have very strict guidelines for how I use whitespace in my code (in VB.Net, I used 0-2 blank lines between things, depending on the situation).

And I actually make very obvious comments in my code. To me, comments are not only to describe the code, but they help me read the code faster, which means comments and whitespace should be both very consistent and should describe each section of code. So I might have:
''' <summary>
''' Information about an animal.
''' </summary>
Public Class Animal

#Region "Constants"
   Private Const HIGHLANDER As Integer = 1
  Private Const BUNCH_MIN As Integer = 10
  Private Const COUPLE_NAME As String = "couple"
  Private Const BUNCH_NAME As String = "bunch"
  Private Const TEMPLATE_DESCRIPTION_SINGLE As String = "There is one baby {1}."
  Private Const TEMPLATE_DESCRIPTION_MANY As String = "There are a {0} of baby {1}s."

#End Region

#Region "Properties"
   ''' <summary>
  ''' The name of this type of animal (duck, hamster, ...).
  ''' </summary>
  Public Property AnimalName As String

#End Region

#Region "Methods"
   ''' <summary>
  ''' Gets a description of the number of children this animal has.
  ''' </summary>
  ''' <param name="count">The number of children.</param>
  ''' <returns>The description ("There are a couple of baby ducks.").</returns>
  Public Function GetChildrenDescription(ByVal count As Integer) As String

    ' Variables.
    Dim description As String
    Dim countWord As String

    ' Choose description based on number of children.
    If count = HIGHLANDER Then
      description = String.Format(TEMPLATE_DESCRIPTION_SINGLE, Me.AnimalName)
      If count >= BUNCH_MIN Then
        countWord = BUNCH_NAME
        countWord = COUPLE_NAME
      End If
      description = String.Format(TEMPLATE_DESCRIPTION_MANY, countWord, Me.AnimalName)
    End If

    ' Return description of children.
    Return description

  End Function

#End Region

End Class

So even though "variables" is obvious, I still keep it there because it allows me to read through code faster (e.g., by skipping over the section with variables). And I don't comment the contants section because I make constants so descriptive that I don't comment them individually and having the region "Constants" acts as a comment for the entire group of constants. I also like XML comments for large chunks of code (methods, classes) because that gives me Intellisense and Visual Studio collapses them for me.
Somebody in an online forum wrote:
INTJs never really joke. They make a point. The joke is just a gift wrapper.

GeneralRe: 21,662 Pin
Sander Rossel24-Sep-11 12:50
professionalSander Rossel24-Sep-11 12:50 
GeneralRe: 21,662 Pin
AspDotNetDev24-Sep-11 14:16
protectorAspDotNetDev24-Sep-11 14:16 
GeneralRe: 21,662 Pin
BobJanova26-Sep-11 4:07
MemberBobJanova26-Sep-11 4:07 
GeneralRe: 21,662 Pin
Sander Rossel26-Sep-11 8:01
professionalSander Rossel26-Sep-11 8:01 
JokeRe: 21,662 Pin
AspDotNetDev26-Sep-11 8:35
protectorAspDotNetDev26-Sep-11 8:35 
GeneralRe: 21,662 Pin
Sander Rossel26-Sep-11 8:38
professionalSander Rossel26-Sep-11 8:38 
GeneralRe: 21,662 Pin
BobJanova26-Sep-11 22:25
MemberBobJanova26-Sep-11 22:25 
GeneralRe: 21,662 Pin
witm553-Oct-11 22:24
Memberwitm553-Oct-11 22:24 
GeneralRe: 21,662 Pin
Sander Rossel4-Oct-11 8:45
professionalSander Rossel4-Oct-11 8:45 
GeneralRe: 21,662 Pin
witm554-Oct-11 10:43
Memberwitm554-Oct-11 10:43 
GeneralRe: 21,662 Pin
Sander Rossel4-Oct-11 10:53
professionalSander Rossel4-Oct-11 10:53 
GeneralRe: 21,662 Pin
TorstenH.26-Sep-11 3:23
MemberTorstenH.26-Sep-11 3:23 
GeneralPower beep Pin
Lutosław22-Sep-11 1:44
MemberLutosław22-Sep-11 1:44 
JokeRe: Power beep Pin
Julien Villers22-Sep-11 22:06
professionalJulien Villers22-Sep-11 22:06 
GeneralRe: Power beep Pin
Lutosław22-Sep-11 22:53
MemberLutosław22-Sep-11 22:53 
GeneralRe: Power beep Pin
Sander Rossel24-Sep-11 3:24
professionalSander Rossel24-Sep-11 3:24 
GeneralRe: Power beep Pin
Pravin Patil, Mumbai25-Sep-11 19:40
MemberPravin Patil, Mumbai25-Sep-11 19:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.