I actually made a video about refactoring python for maya basics a little 
while ago where I talk about some of that exact stuff! Never got around to 
uploading it, I'll do that soon, maybe there will be something helpful in 
it (depending on your coding prowess). 

To echo Marcus, it's hard to be really specific, but once you have a little 
bit of an eye for it, it can become more clear what the threshold is for 
extracting stuff. The example I think I used was: say you're codifying 
your day and you have a function called "waking up". It may seem totally 
reasonable to put all the steps for making and drinking coffee in that 
"waking up" function. Related process and you do it almost every morning. 
But what happens if you want to make a cup of coffee after dinner? It's not 
"wrong" to include coffee-making in the wake-up function, but it can be 
objectively better to extract it into its own function so that you can use 
it later in a different way or in a different script. Turns out it's easier 
to inspect, test and revise later also. 

I LOVE Marco's work, his tutorials and all that are awesome. So I don't 
want to sound like I'm contradicting what he did. But it's also often the 
case that when writing something, one can't be bothered to break everything 
up into the most perfectly efficient chunks. That's why there's a word for 
refactoring:) Sometimes you have to see how things work in the wild and how 
other might use it. Overthinking this stuff can lead to wasting time by 
designing for use-cases that never happen. . . again, that's why we 
refactor.

In the case you mention, it might be worth looking into ways to dissect the 
comparison and filtering process, maybe the traversal process too. Loads of 
levels of indents, etc can indicate that maybe you're trying to do too much 
in one method or function and some of that sorting can be broken out.  
Hope that helps!

-- 
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/1417521d-dd46-4e64-8e76-2067062818b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to