On Sun, Jun 5, 2016 at 8:20 AM Rudi Hammad <[email protected]> wrote:
> hello, > > so I spend a couple of months making my show reel which is a rig builder > tool. Here you have the link if you want to check it > > riggin/programing reel <https://vimeo.com/168109200> > > I learned a lot doing it, and I want to thank this forum for helping me > with my questions (even the stupids ones....) > Any way, now I want to rewrite my code avoiding making some mistakes I did > previously, so I wanted to ask you If I am using the instance variables > right.( code in pastebin link ) > > http://pastebin.com/yxMNRXHT > > I thought that arguments like side, or name are very used in all the > methods, so is it okey to out them in the __init__? this way, I don´t have > to keep using those arguments over > and over again in the rest of the methods. > But of course that obligates me to create the class instance. > If you have a class with only 2 methods, and one of them is __init__(), then you actually want a function: Stop Writing Classes <https://www.google.co.nz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwj93brXr4_NAhWh5aYKHcr2A9kQtwIIIzAB&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D5ZKvwuZSiyc&usg=AFQjCNFmZVxxwQizSaiWoIvyttCxF7eNsQ&sig2=KdZ31zIBfmhaOxVsVG14DA> Now, if you haven't shown us the entire implementation, and you actually have more methods, then maybe a class is correct here. It all depends on whether you need to accept "options" and store state, in order for the rest of the methods with similar purpose can operate. The only suggestion I would have to the way your class is currently written, is to rename your class variable from axex -> Axes (or AXES) to indicate that they are a class variable, and to use a tuple instead of a list to make the collection frozen: AXES = ('x', 'y', 'z') > > I now about classmethods to call directly the class. But then, should all > my methods be classmethods? > Again, if you have a class and all the methods are classmethods, then you just want functions, and to put your class variables into private global variables like: _AXES = ('x','y','x') def makeIk(): ... Classes are for collecting similar behavior and to maintain state. > I don´t know, a programer told me that scripting for 3d I don´t have to > care too much about all that, > Hah. That is very stereotypical. It is what pipeline people refer to as "TD Code". No offense intended here. It is just the term for those that fulfill the stereotype about figuring that code can just be written sloppy since your real goal is to get your artist tasks done now. But what ends up happening is that someone else will need to use it, or fix it. And they will find it doesn't work in a bunch of cases because it was designed for a specific purpose, or it is just so messy that it is hard to understand the intent. The code then becomes throw away code. Point is, if you are going to write code, you might as well develop good habits, while still trying to find a balance between intense over engineering and fast iteration. Basically write your code like someone else is going to read it. > but I don´t want my code just to work, I want to make a proper code too > when > I am applying it to rigging. > Nice. Go with that. > > cheers > > -- > 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/7bea2fb9-4b04-4a60-a42c-e95b0c776422%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/7bea2fb9-4b04-4a60-a42c-e95b0c776422%40googlegroups.com?utm_medium=email&utm_source=footer> > . > 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/CAPGFgA0rEakHL_OjYrNbh3NPJY2uh0r%2BDm8Q_mXHLXfS8dS6gA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
