The premise is using a language (e.g. C#, javascript) which passes an object by reference into a method.
Assume there is an object "Player" which has a property "Level" and there is a method takes Player as parameter and its function is to increase the player's level by 1.
The method can be designed something like (c# syntax):
void AddLevelBy1(Player player)
{
player.Level +=1;
}
The concern was this method changed the value of the argument and I could not find a generic way to indicate (or may prevent?) this.
One might get some hints from the method name "AddLevelBy1". But such a way is not reliable and if the method was name "foo" then it becomes even more ambiguous.
So is there a solution / convention for this case (indicate whether arguments get changed)? Or such method design was considered a bad practice?
Added:
Try to describe my case more clearly:
I have an object "Player" which was not defined by myself (cannot change).
I wrote a method (AddLevelBy1() in this example) which takes "Player" as parameter (I know what happened).
I also pass this "Player" to some other methods (e.g. foo()) which were not written by me (so this is no way to know whether the "Player" got changed).
Thanks for some answers below but what if the codes were designed in the manner I described above.
I have added a demo of the case I described: http://jsfiddle.net/54sun/srhHt/9/
player.addLevelBy1()
if I understand your question correctly.