Is there a school of thought on putting focus on using generic names for functions, opposed to naming functions based on the things they do?
Say we have a
Bill / Price Sheet object, that has line items
Bill: * Shipping Charge $5.00 * Crate Charge $6.00 * Tax Charge $8.00
Generic function names would be:
//function's code knows how to add a line item bill->addLineItem("Shipping Charge", 5); bill->addLineItem("Crate Charge", 6); bill->addLineItem("Tax Charge", 8);
Specific function names would be:
//function's code reflects knowledge of this specific line item bill->addShippingCharge(5); bill->addCrateCharge(6); bill->addTaxCharge(8);
This can be extended to any set of similar actions where something similar is being done. A more generic function takes the actual parameter, and can be deemed more flexible - any new line item can be added using the same function. A more specific function can only be used for that particular line item. Adding a new type of line item requires a new function. Something tells me that the specific way is more preferred, but I can't verbalize why, and maybe I am wrong. But perhaps it makes the code more clear as to what this line item is intended to do.
So if specific naming is superior, and I am writing code for a restaurant with 600 items on the menu (such restaurants do exist), I am not sure I want to have 600 unique functions for each menu item. But in that case maybe a different approach is warranted. So what I am asking here, is if I have a reasonable class of items (i.e. 10-20) for my specific possible line item list, would you recommend any particular approach from the ones described (specific vs general), or does it all depend on my project specifics?