Naming a template print method properly Some might not think it's worth asking but I consider good function names quite important. I am not sure what should be the overridable function name in what I think is template design pattern. I am printing a report which has 3 types. There are lots of if-else which is confusing. I replace the long function with the polymorphic class hierarchy with base class below. I have than derived a class from each report type which overrides the PrintCustom() function but this doesn't strike me as a good name.

class CPrintReport
{
protected:
    CPrintReport(void);
public:
    virtual ~CPrintReport(void);

    // template function?
    void PrintReport();

protected:
    void PrintCommon();
    virtual void PrintCustom() = 0;
    virtual void PrintChart();


protected:
    CStringArray pstrData;

    CGraphCtrl * m_GraphCtrl;

};


PrintReport is the main function which is as following:

void CPrintReport::PrintReport()
{
    // prints thte common data
    PrintCommon();

    // prints specialized (verification,identification or regular type)
    PrintCustom();

    PrintChart();

}



Does this implement the template design pattern where PrintReport() is the template function?
As you can see from report, the first section prints common information, and the last section prints a chart, but the middle section varies based on what type of report it is. If it was procedural programming I would be calling this PrintVerificationData()and PrintIdentifcationData() depending on which type of report is being printed. How do we name such methods in the template design pattern so it makes better sense?
It turns out PrintChart is going to be different as well for each type. However, it is the same for 2 types (verification and identification) and different for regular print. Does this mean PrintChartVerifyIdentify() (being lazy but making a point) should reside in the base class so it can be shared, or should I use a visitor pattern or something?
I think you're right to be concerned with the names you're using.

I'd start with the name of the base class. CPrintReport strikes me as a rather poor name. First of all, it sounds like a verb phrase (Print Report). Most classes should be nouns. Second, you typically want the name to reflect the fact that it's an abstract base class. Finally, tacking a C onto the beginning of a class name is, frankly, a pretty lousy idea.

I'd probably start with a report namespace, and name this base:

namespace report {    
    class Base {
        // ...
    };    
}


The other reports would derive from it, so you might have something like:

namespace report { 
    class Verification : public Base { 
        // ...
    };

    class Identification : public Base { 
        // ..
    };    
}


Then when you want to print one, your code would be something like:

report::Verification verification_report;
verification_report.print(printer);


As far as the names of the individual functions go, I think the problem is fairly simple: right now, your names basically reflect the mechanics of generating the reports. I'd prefer to see names that reflect the sections of the report they generate instead.

For example, your PrintCommon, PrintCustom and PrintChart might become: PrintIntroduction, PrintDetails, and PrintSummary respectively. Of course, I don't know for sure how your reports are structured, so there might be other names that make more sense, but the basic idea still applies--to the extent possible, base the names on their effect in the final product rather than on the details of how you're implementing the code.