The Utility Belt



  • This was submitted anonymously ...

    My highlights include:

    1.Overall.  All the logging.  Put a link up the the Enterprise Library.  Also notice the complete lack of commenting, oh and the variable naming standards are god aweful.

    2. Useless wrapper methods...
    Private Function ConvertStr2ByteArray(ByVal strInput As String) As Byte()
    --In the comments there is discussion about changing to System.Text.ASCIIEncoding.Default.GetBytes(string) but it still is not done in the code.  I thought that this is brutally funny.  To decide that something is crap, find an alterantive and much better solution and then simply not change it!  What are you thinking!?

    3. The use of single ByRef parameters and using a sub, that I find quite strange.
    Example:
    Sub DBPopulate(ByVal strConn As String, ByVal strSQL As String, ByRef string1 As String)

    4. This just scares the shit out of me:
    Dim strTask As String = "SUB DBPopulate / hash=3rd parm object, object=4th parm"

    5. Function WebConfigGrab(ByVal strkey As String) As String
    is a wrapper for
    Private Function appkey(ByVal strParm As String) As String
    which is a wrapper for the .NET AppSettings stuff

    6. Private Sub XMLNodesToArray(ByVal htParams As Hashtable)
    Its emtpy. Glad that is documented.

    7. Function XMLToDataSet(ByVal strFilename As String) As DataSet
    You would think that takes XML by the function name, but instead a filename itself.  There are a few methods like this.  Dataset's from disk?  Sort of scarey if you ask me.

    8.  public Sub Xray(ByVal p1 As Object, ByVal p2 As String)
    The entire Xray thing. Give the author(s) credit for the sheer amount of work that went into this thing but consider reflection!

    And of course the entire 6000+ lines of code is in a SINGLE class.  I'm sure 100 people could find 100 more things that just make you want to scream WTF!

    Can you believe this guy wants money via donations for this?



  • <font size="2">Holy spaghetti code, batman()!



    Does that utility belt include a can of VB Repellent?



    </font>



  • Wow that's a lot of weird shit...

    The ByRef thing is funny. Maybe he thinks he's making his code more efficient by passing in his string variable by reference and updating it within the sub rather than taking up all those precious bytes of memory to send a string as the return value.

    Then later in the code he has functions that return booleans, strings, DataTables... *sigh* I love inconsistent programming. This must be a result of the "<FONT face=Arial size=4>help by Jeff, Steve and Dave<FONT face="Times New Roman" size=3>". In other words, take the code they wrote, and paste it directly in to his garbage code.</FONT></FONT>

    At least when an error occurs, you'll be able to find it easily. You'll have to wade through thousands of log messages...



  • Oh my.
    I'm not a VB coder, but this thing is a huge bunch of shit. This is clearly not what I'd tout as best coding practice for the purpose of learning... Yet they do exactly this, as this is apparently part of an online programming book.

    Read this and weep: http://www.learnasp.com/freebook/learn/utilitybelt_faq_blackbox.aspx

    Looks like we finally found this elusive school of WTF programming that spawns all those nightmarish programmers.



  • Wow.  Just... Wow.

    Using "Option Strict Off" or "Option Explicit Off" should cause VS.Net to pop up a little window saying "Lern to code!" (sic).



  • The first thing I noticed while watching this "gem" is that the horizontal scroll was active so I looked for the line that caused this to happen. I find this

    <FONT size=2>Dim keywords() As String = {"Private", "Protected", "Public", "End Namespace", "Namespace", "End Class", "Exit", "Class", "Goto", "Try", "Catch", "End Try", "For", "End If", "If", "Else", "ElseIf", "Next", "While", "And", "Do", "Loop", "Dim", "As", "End Select", "Select", "Case", "Or", "Imports", "Then", "Integer", "Long", "String", "Overloads", "True", "Overrides", "End Property", "End Sub", "End Function", "Sub", "Me", "Function", "End Get", "End Set", "Get", "Friend", "Inherits", "Implements", "Return", "Not", "New", "Shared", "Nothing", "Finally", "False", "Me", "My", "MyBase"}
    </FONT>       

    So I started to be quite... scared. Then I saw:

                <FONT color=green>' 1st parameter as array    C# hated that</FONT>
                <FONT color=green>'               as string() C# hated that</FONT>

    And I feel really scared, but I'm brave so I keep scrolling up (yes, I was going down->up) and saw:

    <FONT size=2>        <FONT color=blue>Private</FONT> <FONT color=blue>Sub</FONT> AAATemplate()
                <FONT color=green>' DIM everything that needs to be seen by CATCH or FINALLY block</FONT>
                <FONT color=blue>Dim</FONT> strTask <FONT color=blue>As</FONT> <FONT color=blue>String</FONT> = "<FONT color=blue>SUB</FONT> AAATemplate"
                <FONT color=blue>Try</FONT>
                    LogTaskStart(strTask)
                    ' LogTaskEndPremature(strTask,"reason for quitting early")
                    ' LogFlow(strTask,"some branch people want to know about with UBFlowon")
                    ' LogDebugData(strTask,"varname=" & varname)
                    ' LogWarning(strTask,"some high level warning for the developer")
                    LogTaskEnd(strTask)
                <FONT color=blue>Catch</FONT> ex1 <FONT color=blue>As</FONT> Exception
                    LogException(strTask, ex1) <FONT color=green>' Used for most exceptions</FONT>
                <FONT color=blue>Finally</FONT>
                    <FONT color=green>' Release(Conn1)</FONT>
                    <FONT color=green>' Release(Conn1)</FONT>
                    <FONT color=green>' Release(stream1)</FONT>
                    <FONT color=green>' Release(Rdr1)</FONT>
                    <FONT color=green>' Release(Rdr1)</FONT>
                <FONT color=blue>End Try</FONT>
            <FONT color=blue>End Sub</FONT></FONT>

    So, let's analyze this:

    1º Proper function (sub) name: AAATemplate()

    2º <FONT color=#008000 size=2>' DIM everything that needs to be seen by CATCH or FINALLY block</FONT>

      At this point he's instructing us in the complexities of the variable scope

    3º <FONT size=2>            <FONT color=blue>Catch</FONT> ex1 <FONT color=blue>As</FONT> Exception
                    LogException(strTask, ex1) <FONT color=green>' Used for most exceptions</FONT></FONT>

        We will call it proper exception handling 

    4º <FONT size=2>            <FONT color=blue>Finally</FONT>
                    <FONT color=green>' Release(Conn1)</FONT>
                    <FONT color=green>' Release(Conn1)</FONT>
                    <FONT color=green>' Release(stream1)</FONT>
                    <FONT color=green>' Release(Rdr1)</FONT>
                    <FONT color=green>' Release(Rdr1)</FONT></FONT>

    This code can be replaced for:

       <FONT size=2> <FONT color=green>' ReleaseNothing()</FONT></FONT>

    5º <FONT color=#0000ff size=2>End Try</FONT>

    And that's the best thing of all, just end trying, please.

    About the donations -> I'm feeling like I can donate, but not money, maybe a primer on how to program

    End Note: Not to forget that it's VB so ... maybe he put the language to it's limits [:P]
                 



  • @Taliesin said:

    And that's the best thing of all, just end trying, please.



    Ah yes, I propose and extension to VB:

    Give Up



  • @Alex Papadimoulis said:

    Can you believe this guy wants money via donations for this?





    Here is the donor list of people who apparently thought that his code
    is worth something.... I'm particularly pleased to see someone from
    Redmond,Seattle donate.  😉



    Since I started the tip plan in August 2004 I have recieved the following tips:
    • $5 from Steve Owens of Lilberg, GA
    • $20 from Rob Caron of Redmond,Seattle
    • $39 from Nicholas Vu from Walnut, CA
    • $200 from Pete Brunone of Texas
    • $200 from Doug Nelson of synappnorth









  • @TankerJoe said:

    @Alex Papadimoulis said:

    Can you believe this guy wants money via donations for this?





    Here is the donor list of people who apparently thought that his code
    is worth something.... I'm particularly pleased to see someone from
    Redmond,Seattle donate.  😉



    Since I started the tip plan in August 2004 I have recieved the following tips:
    • $5 from Steve Owens of Lilberg, GA
    • $20 from Rob Caron of Redmond,Seattle
    • $39 from Nicholas Vu from Walnut, CA
    • $200 from Pete Brunone of Texas
    • $200 from Doug Nelson of synappnorth



    Hey, if anybody know Pete or Doug's e-mail addresses, I am in need of $200 each too!  I'll even provide a much less convoluted Utility Belt!  Seriously, I vote hoax on the tips, just trying to make it look good and "guilt" you into donating.  An "A" for effort and an "F" in execution.

Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.