News for hackers. Stuff that matters.
Re:Self-Commenting Code by asimjalis on Wednesday April 23, 2008 @10:32AM (#171522)
Why not break them out into separate functions? Use the comments to name these functions. Each comment is a hidden function. Also this will reduce code duplication? For example,

  char* findEnd( char* s)
  {
    while( *s ) s++;
    return s;
  }
  
  bool endsWith( const char* haystack, const char* ending )
  {
    // find the end of [haystack] and [ending].
    const char *haystackEnd = findEnd(haystack);
    const char *endingEnd = findEnd(ending);
  
    // Etc.
  }

There are no comments on this comment yet.