2 ms·
"Then Hit reaches into said objects and deals with changing the HP, and XP." This is not essentially different from what happens in non-OO code. OO purists wou
by mannykannot 8y ago
"Then Hit reaches into said objects and deals with changing the HP, and XP."
This is not essentially different from what happens in non-OO code. OO purists would probably object to this as a violation of encapsulation, and would insist on objects receiving a hit performing the update to their state themselves.
Stepping back from this example and considering transactions in general, it is often the case that there are certain constraints to be observed, and in such cases, it is easier to verify the solution if it is done compactly in one function. In such cases, creating a class and instantiating it just to have that function would be pointlessly excessive obeisance to a principle, and making it a singleton would only underscore that point.