Hmm , the little overhead of the MPlug way is really negligible / small if we 
talk about using it in C++, however for Python I don’t know so … I mean it 
brings so much advantages … I would’ve though that maybe there was a dark 
profound issue with doing it , I guess it’s all good as long as you use it in a 
low-level language and you don’t use it to set/get values of course …

Sent from Mail for Windows 10

From: Marcus Ottosson
Sent: Saturday, March 17, 2018 4:14 PM
To: [email protected]
Subject: Re: [Maya-Python] Why most people use boolean flags insteadofcatching 
the MPlug ?

Thanks, I think that's much clearer.
In this case, one immediate advantage of using a bool is performance. Querying 
a boolean is simply faster than calling a function.
If performance wasn't an issue, then I would likely still opt for a boolean as 
a means of communicating what it is being used for. You could argue that you 
should always pass the full APIs of objects around, to maximise your ability to 
take full advantage of them wherever they are being intercepted. In my 
experience this leads to brittle and stale code. Consider for example if you 
made a change to your code whereby you were no longer using `MPlug` to retrieve 
plug dirtiness. What if there was a faster method? In that case, you will 
either have to (1) instantiate a dedicated `MPlug` simply to pass it along 
(slow), (2) build your own `MPlug` replica that mirror the interface of the 
original `MPlug` such that any method using the member still works (slower), or 
(3) refactor anything that uses that member variable to use the new return 
value (painful, maybe). If instead all you passed was a boolean, then the odds 
are greater that you'd be able to use the new method, and still pass a boolean. 
Subsequent methods could remain untouched (and blissfully unaware of your 
improvement).
-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOB_8T3q03UrPtPanvCEz1b53oByiV39nhBFru02f7xF2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/5aad44d0.8587df0a.61cae.b1e2%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to