Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualmhagain

Posted 26 April 2013 - 08:21 AM

// this is fine
if (this->SomeCondition())
{
    SOME_DATA_STRUCT* d = this->GetDataStruct();
    this->DoThis(d);
    this->DoThat(d);
}

 

This is fine indeed - until a coupla years later you come back to the code and find that maintenance/evolution/whatever has added 200 extra lines of code between your "SOME_DATA_STRUCT* d = this->GetDataStruct();" and your "this->DoThis(d);".  Then it stops being fine and you'll wish you'd given it a better name first time round.

 

That's kinda the point here.  Code isn't static; you don't just write it once and then leave it be forever more, and even if you think you will, trust me - you won't.  So you always write with the assumption that code is going to be revisited, worked over, bugfixed, have functionality added, and generally sprout all kinds of interesting tentacles in all kinds of interesting directions during it's lifetime, and that way you're protected when (and it is a "when", not an "if") that time does (and it is a "does", not a "may") come.

 

At the very least pick a name such that doing a search for all occurrances of that name in your codebase will give you what is genuinely all occurrances and nothing else.


#1mhagain

Posted 26 April 2013 - 08:19 AM

// this is fine
if (this->SomeCondition())
{
    SOME_DATA_STRUCT* d = this->GetDataStruct();
    this->DoThis(d);
    this->DoThat(d);
}

 

This is fine indeed - until a coupla years later you come back to the code and find that maintenance/evolution/whatever has added 200 extra lines of code between your "SOME_DATA_STRUCT* d = this->GetDataStruct();" and your "this->DoThis(d);".  Then it stops being fine and you'll wish you'd given it a better name first time round.

 

That's kinda the point here.  Code isn't static; you don't just write it once and then leave it be forever more, and even if you think you will, trust me - you won't.  So you always write with the assumption that code is going to be revisited, worked over, bugfixed, have functionality added, and generally sprout all kinds of interesting tentacles in all kinds of interesting directions during it's lifetime, and that way you're protected when (and it is a "when", not an "if") that time does (and it is a "does", not a "may") come.


PARTNERS