Hello again, I am trying to improve my coding, to make clean and easy for others to read as I posted in other threads. This time I wonder about how many lines per function/method I shoud do. I read that recently on stack overflow
*It's not about lines of code. As Steve Mcconnel and Bob Martin say (two pretty good references on coding best practices), * *a method should do one thing and only one thing. However many lines of code it takes to do that one thing is how many lines it should have. * *If that "one thing" can be broken into smaller things, each of those should have a method.* *Good clues your method is doing more than one thing:* - *-->More than one level of indention in a method (indicates too many logic branches to only be doing one thing)* - *-->"Paragraph Breaks" - whitespace between logical groups of code indicate the method is doing more than one thing* *Just to name a few. Bob Martin also says to keep it around 10. Personally I usually try to shoot for 10. If it starts getting close to 20* Really 10 or 20? I just wrote a method with 80 lines... I can“t post it because it from work, but what this method does basically is navigate through a treewidget, and depending on the kind of item below or above, it compares that item to the selected one, and as a result it will behave diferently. But anyway, generally speaking, do try to keep you methods around 10/20 lines, I find it hard to do. Also, I recently studied at rigging dojo a C++ course, and the tutor, Marco Giodiano who in my opinion is amazing, did quite long functions I believe. Is C++ another world from Python regarding all this conventions? thanks R -- 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/b34c76bb-fac5-4119-abf1-0b5d1f6954ac%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
