Welcome Guest, Not a member yet? Register   Sign In
Tracking down model calls
#4

As CroNiX mentioned, I usually just use the search/find features of my editor to track them down, and I usually just search for the model name in all lowercase (or case-insensitively), without bothering with the -> or $this. If my model's class name isn't unique for some reason, this process would just serve as a reminder for why that's important, and context will tell me whether the found result is relevant.

Further, though, I would work on figuring out why you need to do this in the first place. In general, you should avoid modifying an existing model in a way which would require you to update all (or multiple) uses of the model or a given method in the model. For example, if I need to add an argument to a method for some reason, I add it to the end of the argument list with a default value which gives me the existing behavior, so I only need to modify the call to the model's method in the case(s) where the new behavior (and associated parameter) is necessary.

The primary reason I end up searching for all calls to an existing method is when I rename a method. In that case, I deprecate the existing method and turn it into an alias for the new method, so my existing calls still work until I have a chance to change them. I usually mark deprecated methods with a comment including the version or date of the deprecation, so the information is readily available when I run across the method later. In my application, I usually try to commit the deprecation of the method and the changes to other parts of the code to use the new method as separate commits, in case something goes wrong in changing the other files. When I come back to the model in the future, if the deprecated method is old enough, I can search for uses of the method to determine whether it is safe to remove it.
Reply


Messages In This Thread
Tracking down model calls - by PaulD - 08-04-2015, 09:53 AM
RE: Tracking down model calls - by CroNiX - 08-04-2015, 10:01 AM
RE: Tracking down model calls - by PaulD - 08-04-2015, 10:11 AM
RE: Tracking down model calls - by mwhitney - 08-04-2015, 10:19 AM
RE: Tracking down model calls - by PaulD - 08-04-2015, 11:21 AM



Theme © iAndrew 2016 - Forum software by © MyBB