Window Dressing

last modified: August 20, 2010

WindowDressing (a cousin of YouDontNeedItAnymore) is frilly, extraneous code that dresses up existing code, without adding any value. WindowDressing code should be refactored.

Here's an example (pardon the VB syntax but I took this stinker from real code submitted for CodeReview):

Dim i As Integer
For i = 1 To 3
    Select Case i
        Case 1
            ' first block of code
        Case 2
            ' second block of code
        Case 3
            ' third block of code
    End Select
Next i

Refactored solution:

' first block of code
' second block of code
' third block of code

Note: the variable i was never used in the code blocks within the Select statement, so other than reformatting and removing the WindowDressing code, the underlying code -- which provided all the functionality -- is unblemished.

I've seen something similar in C, except that the loop had an extra termination condition, allowing you to bail out of a multi-step process. It's apparently called a "stepper loop". I think that it's still a smell, though.

A smell? CodeStench ahoy. The infamous GoTo would be cleaner! -jh


AntiIdiom CodeSmell


Loading...