Disclaimer:
These pages about different languages / apis / best practices were mostly jotted down quckily and rarely corrected afterwards.
The languages / apis / best practices may have changed over time (e.g. the facebook api being a prime example), so what was documented as a good way to do something at the time might be outdated when you read it (some pages here are over 15 years old).
Just as a reminder.

scribblings about C++

sample cpp code

dump me

If necessary it can be useful to implement a method DumpMe in each class, that makes it easy to print out the values of all attributes when debugging.
The DumpMe was quite useful when I got some horrible C++ code (basically it was coded like a Vic 64 Basic spagetthi program, but at least goto was not used but probably only becuase the person that coded the thing didn't know about goto in C++) that I needed to do changes in, and it was really useful to be able to easily print what values the objects had.

Normally the DumpMe will never be called, but when you want to debug, you edit the source and call DumpMe whereever you want to get the values of all attributes.
You call the DumpMe simply like this:

this->DumpMe(0,1);
i.e. the depth is always 0 at start, and the 1 is for verbose output This is what a sample DumpMe method will look like:
void Basispart :: DumpMe(int iDepth, int iVerbose)
{
  //first call the parent DumpMe
  ParentObj::DumpMe(iDepth, iVerbose);
  int loopDepth=iDepth;
  RWCString sTab="";
  while (loopDepth>0)
  {
    sTab +="|";
    loopDepth--;
  }

  //the object contain a list with strings
  RWTValDlist<RWCString>::iterator iter = this->dilbertcomics.begin();
  RWTValDlist<RWCString>::iterator theEnd = this->dilbertcomics.end();
  
  cout << sTab << "Number of Dilbert comics:		" << dilbertcomics.entries() << " entries" << endl; 
  if(iVerbose>0)
  {
    while(iter != theEnd)
    {
      cout << sTab << " " << *iter << endl;
      ++iter;
    }

    //If the object contains for example a list with pointers to other objects, you will dump them as well
    // (and increase the depth so that you get nice identation in the output)
    if(this->otherObjects.entries()>0)
    {
      cout << sTab << "\ otherObjects" << endl;
      for(int b=0; b < this->otherObjects.entries(); b++)
      {
        this->otherObjects[b]->DumpMe(iDepth + 1, iVerbose);
        cout << sTab << "----" << b << "-----" << endl; 
      }
      cout << sTab << "/ otherObjects" << endl;
    }
  }
}

More programming related pages

Workflow: Release process
Workflow: Bug tracking
Teambox (Redbooth) - Mantis connector
Design Patterns
Git & Github
Go / Golang
CVS
CVS backup script
Distribution process
Installation script
Java Server Faces
Facelets
jibx
jBoss
jBpm
Perl tips
Perl links
PostgreSQL
Python / py2app
Shell scripts
Xslt
Node.js
Facebook / Opengraph
PHP developer notes
Redbooth API through php
Website optimization
jqTableKit demo
Javascript / html / css links