View on GitHub

Training Material

Goals For Better Programming : Sean Parent C++ Seasoning

(JP 07/11/2014 originally presented this taster for the talk with supporting slides from Sean Parent C++ Seasoning)

Supporting material: Going Native 2013:Sean Parent “C++ Seasoning”

Some Highlights

Goals:

Why? Locality of reasoning:

Striving with the ‘no raw loops’ goal:

Look for simple example improvments in own code base


// Fail the 'No raw loop' goal
bool HasValidProperty( const Object& object )
{
  //
  // See if object's property is currently in use.
  //
  const auto objectProp = GetObjectProperty( object );
  for( const auto& prop : CurrentProperties() )
  {
    if ( prop == objectProp )
    {
      return true;
    }
  }
  return false;
}

// Achieve the 'No raw loop' goal
bool HasValidProperty( const Object& object )
{
  return boost::algorithm::any_of_equal(
    CurrentProperties(),
    GetObjectProperty( object ) );
}

Presented at IndigoVision during a training session on 07/11/2014 with supporting slides from Sean Parent.

Creative Commons Licence
This work by Jean-Philippe DUFRAIGNE is licensed under a Creative Commons Attribution 4.0 International License.