TubularX
October 19th, 2008, 11:21 AM
If I want to add a copy method to my "Car" class, is it better to name it "CopyCar()" than just "Copy()"?
That would make it easy to search for all places where the specific copy method was called, as opposed to if every class had a copy method with the same name (for every search result, you would have to consider the context). Is this of importance or not?
If the class was inherited, the method name would of course depend on the base class (if it's intended to be used polymorphically). Also here, the shared name could be either "Copy" or let's say "CopyVehicle".
What do you recommend? Advantages and disadvantages of adding the class name to the end of common method names?
That would make it easy to search for all places where the specific copy method was called, as opposed to if every class had a copy method with the same name (for every search result, you would have to consider the context). Is this of importance or not?
If the class was inherited, the method name would of course depend on the base class (if it's intended to be used polymorphically). Also here, the shared name could be either "Copy" or let's say "CopyVehicle".
What do you recommend? Advantages and disadvantages of adding the class name to the end of common method names?