Programmer's Purgatory

I don't ordinarily subscribe to any judeo-christian hocus-pocus.

But i have a vague feeling that when programmers die they are made to spend many centuries in a purgatorial-place, as punishment for all the bad code, the slow code, the sloppy code, the unmaintainable code...

Here's a recent slab that probably earnt me a couple of millennia in the cosmic wait-state:

Imports System.Text.RegularExpressions

Public Function DisPascalize(ByVal psPascalString As String) As String
  Dim sResult As String
  sResult = psPascalString
  sResult = Regex.Replace(sResult, "([^A-Z])([A-Z])", "$1 $2").Trim
  sResult = Regex.Replace(sResult, "([A-Z])([A-Z])([^A-Z])", "$1 $2$3").Trim
  sResult = Regex.Replace(sResult, "([A-Za-z])([0-9])", "$1 $2").Trim
  sResult = Regex.Replace(sResult, "([0-9])([A-Za-z])", "$1 $2").Trim
  Return sResult
End Function

Notice the way there are no comments at all. Because 'DisPascalize' is just so self-explanatory, no?

What does it do?

"PascalCase""Pascal Case"
"ABCPascal""ABC Pascal"
"Pascal123""Pascal 123"
"123Pascal""123 Pascal"

I've used it for converting PascalCase Enums into presentable words. Wonder if anyone has advice on a nicer way to do this. It feels so wrong.


My book "Choose Your First Product" is available now.

It gives you 4 easy steps to find and validate a humble product idea.

Learn more.

(By the way, I read every comment and often respond.)

Your comment, please?

Your Name
Your Url (optional)
Note: I may edit, reuse or delete your comment. Don't be mean.