What is the accepted naming convention for methods that modify or slightly change a passed parameter object?
In particular, methods like this:
class Mapper {
public PersonDTO MapPerson(tPerson p) {
var person = new PersonDTO {
ID = p.ID,
Name = p.Name,
Country = Retriever.GetCountryName(p.CountryID)
};
return person;
}
}
Since the “person” descriptor applies to both the return object as well as the parameter, I’m not sure what’s best practice here.
problem solved?
your extra variable could be described as code smell.
if you need to an additional variable, call it
resultorretval. if it is not an return value, call itpersonDto.and for the method, always describe what you you do. in this case, you map a person, so
MapPersonseems fine to me.