Article 5EHJ6 CodeSOD: A Lack of Progress

CodeSOD: A Lack of Progress

by
Remy Porter
from The Daily WTF on (#5EHJ6)

Progress bars and throbbers are, in theory, tools that let your user know that a process is working. It's important to provide feedback when your program needs to do some long-running task.

Hegel inherited a rather old application, written in early versions of VB.Net. When you kicked off a long running process, it would update the status bar with a little animation, cycling from ".", to "..", to "...".

 Private Sub StatusRunningText(ByVal Str As String) If ServRun = True Then Select Case Me.Tim.Now.Second Case 0, 3, 6, 9, 12, 16, 19, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 59 Me.StatusBarPanel1.Text = Str + "." Case 1, 4, 7, 10, 13, 17, 20, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58 Me.StatusBarPanel1.Text = Str + ".." Case Else Me.StatusBarPanel1.Text = Str + "..." End Select End If End Sub

Now, you or I might have been tempted to use modulus here. Second % 3 + 1 is the exact number of periods this outputs. But how cryptic is that? It involves math. This developer has lovingly handcrafted their animation, specifying what should be displayed on each and every frame.

Modular arithmetic is math, but this code, this is art.

Bad art, but still, art.

otter-icon.png [Advertisement] Otter - Provision your servers automatically without ever needing to log-in to a command prompt. Get started today! TheDailyWtf?d=yIl2AUoC8zABqaORtgzAbo
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments