Naming convention for different types of functions (use prefixes or suffixes?)

namingnaming-standards

Does anyone have suggestions for naming conventions for different types of functions, particularly wrapper functions that need to connect to and disconnect from the database vs. wrapper functions that are passed a db link and don't need to connect and disconnect?

The project on which I am working has these types of functions (among other types):

  • wrapper functions that need to connect to the database, then call other functions, then disconnect

  • wrapper functions that are passed a db link and call other functions (these functions don't need to connect to the db, that has already been done)

Has anyone worked in a similar environment? Did you follow any naming conventions to distinguish between these wrapper functions that need to connect vs. being passed a db link, such as using a particular prefix or suffix?

Best Answer

If you are using an OO language that has polymorphism, it should already be apparent from the method signatures which method you need to call:

bool SaveCustomer(Customer cust)
{
    var conn = new DatabaseConnection(connectionString);
    SaveCustomer(conn, cust);
}

bool SaveCustomer(DatabaseConnection conn, Customer cust)
{
    // Save the customer
}
Related Topic