Only recently, I stumbled upon a code fragment that performed something akin to sudo on a webshop. It took a customer_id from the request, checked the logged-in customer's permissions, and then it went about and set a
realCustomer
to the customer from the session... or it set the customer from the request to the realCustomer, while the session customer remained untouched.... or...
See what I'm aiming at?
If you're ever tempted to use something like "real" to distinguish between two objects, please take the time and think about what that object actually represents. The adminCustomer, maybe, the loggedInCustomer, or the effectiveCustomer. But never the realCustomer.
thesaurus.com is a valuable, and deeply underappreciated, resource for coders.
Keine Kommentare:
Kommentar veröffentlichen