Being extra careful



  • Thanks for checking, guys. Nothing could possibly go wrong now.

    if (row1[0]["StartDate"].ToString() != "")
    {
    	DateTime dateTime1 = DateTime.Parse(row1[0]["Start"].ToString());
    }
    

    this.SomeDate = Convert.ToDateTime(row1[0]["Start"].ToString());

    this.SomeOtherDate = Convert.ToDateTime(row1[0]["Start"].ToString());

    this.YetAnotherDate = Convert.ToDateTime(row1[0]["Start"].ToString());

    That's right. The people who wrote this as contractors got paid double what I do as an employee.



  • Oh great.... the thing about dateTime1.... it can never be used since it comes out of scope after the if loop... what a worthless piece of code.



  • I try not to laugh too loudly, as I have contractors sitting right by me.



  • @pitchingchris said:

    Oh great.... the thing about dateTime1.... it can never be used since it comes out of scope after the if loop... what a worthless piece of code.

    I'm guessing it's the result of a bug fix.  Originally it said:

     

    if (row1[0]["StartDate"].ToString() != "")
    {
    	DateTime dateTime1 = DateTime.Parse(row1[0]["Start"].ToString());
    }
    

    this.SomeDate = dateTime1;

    this.SomeOtherDate = dateTime1;

    this.YetAnotherDate = dateTime1;



  • @newfweiler said:

    @pitchingchris said:

    Oh great.... the thing about dateTime1.... it can never be used since it comes out of scope after the if loop... what a worthless piece of code.

    I'm guessing it's the result of a bug fix.  Originally it said:

     

    if (row1[0]["StartDate"].ToString() != "")
    {
    	DateTime dateTime1 = DateTime.Parse(row1[0]["Start"].ToString());
    }
    

    this.SomeDate = dateTime1;

    this.SomeOtherDate = dateTime1;

    this.YetAnotherDate = dateTime1;

    That would be quite a bug... it wouldn't compile.



  • @djork said:

    @newfweiler said:

    @pitchingchris said:

    Oh great.... the thing about dateTime1.... it can never be used since it comes out of scope after the if loop... what a worthless piece of code.

    I'm guessing it's the result of a bug fix.  Originally it said:

     

    if (row1[0]["StartDate"].ToString() != "")
    {
    	DateTime dateTime1 = DateTime.Parse(row1[0]["Start"].ToString());
    }
    

    this.SomeDate = dateTime1;

    this.SomeOtherDate = dateTime1;

    this.YetAnotherDate = dateTime1;

    That would be quite a bug... it wouldn't compile.

     

    It would compile if dateTime1 is named in the class declaration outside this function. Good variable names though (NOT). 



  • @pitchingchris said:

    It would compile if dateTime1 is named in the class declaration outside this function. Good variable names though (NOT). 

    Unfortunately it's not, and that's the beauty of this code. It's a cute but wasted effort. The variable names get better as time goes on (table1, text1, text2, text3, row1, row2, etc.).



  • @djork said:

    @pitchingchris said:

    It would compile if dateTime1 is named in the class declaration outside this function. Good variable names though (NOT). 

    Unfortunately it's not, and that's the beauty of this code. It's a cute but wasted effort. The variable names get better as time goes on (table1, text1, text2, text3, row1, row2, etc.).

    Ok i agree, text1 is a bit wonky, but after that text 2 and 3 are pretty easy. There like right next to text1.

    And row1 and row2 are even more straight forward, the only down side is that you will need to make changes to the program when more rows get inserted into table1.


    And as a contractor those are new billable hours.  Let's call it 'manual program scaling optimisation', it ensures a high grade of accuracy in the monitoring of scaling requirements and data growth.



  • @djork said:

    That's right. The people who wrote this as contractors got paid double what I do as an employee.

    I'm not sure who the idiot is, then...


Log in to reply