But the way these resources usually get manipulated is very problematic.
What or Who?Basically, there are two ways to accomplish a destructive action:
- You can first decide that you want to destroy something (what to do), and only after making that decision will you choose who will be destroyed
- You can first decide who needs to be destroyed, and will only then perform the destructive action (what to do)
What we see here is the decision to first switch to the what mode ("I'm now switching to the slash-and-burn mode"), and only after that the decision is made as to who to delete. The mode (i.e. delete) is declared first, and only after that do we get the identity of the resource to be deleted.
This is disturbingly wrong. It is much more advisable to switch the order of doing things, and to first decide on who is it that needs to be modified/deleted. Once the resource has been fully identified, we can perform the desired action, such as delete or update, etc.
So in the above example, we would simply say:
By doing that, we will first fully identify the resource ("it's the resource x"). Only after doing that (i.e. after obtaining the handle on the resource), will we send it a message to change itself (such as delete).
This results in a much clearer, much less ambiguous implementation.