AlanW Posted July 7, 2016 Share Posted July 7, 2016 Hi, Could someone with experience look at this node and rewrite it the way is should be written. I hacked one and got it to give you a choice to div, mul, add &div. Nice to see how it should be done. Thanks Quote Link to comment
Marionette Maven Marissa Farrell Posted July 7, 2016 Marionette Maven Share Posted July 7, 2016 Hi Alan, What you've written is acceptable. The only thing I've noticed is that you used this line twice: calc = self.Params.calc.value Every user/programmer will have their own style of coding, it's up to you to use whatever you like best. I think that your code is very easy to understand, so I don't think there's an issue with you writing this way. A few notes that don't REALLY matter: 1) Although using "Marionette.TupleMap" makes sense in Marionette networks, I've found it better practice to use use the standard operators on the small scale. (+, -, *, /) 2) Adding comments to your code will always assure that the user can follow what you're doing. I'm glad you used the comments to say which operation is being used for which option. 3) In the Params class, maybe you'd like to add descriptions using .SetDescription to the a, b, and c ports - this will allow descriptions of each of those to appear in the "Description" dialog brought up by the button in the OIP. That is another great way to help a user understand what a node does or requires to work. I personally believe that the most important part of coding is creating code that an unexperienced user will be able to understand moderately easily. It's also very beneficial to comment code because you may return to a project from months or years ago and not remember what a certain part does off the top of your head, or you may not remember why you did it a certain way. Hope this helps! Quote Link to comment
AlanW Posted July 7, 2016 Author Share Posted July 7, 2016 (edited) Marissa, Thanks for this so the added option is the way you have suggested. Any reason for this?? other than above? Have re-read the above and much clearer bit slow here LOL Edited July 7, 2016 by Alan Woodwell Quote Link to comment
Marionette Maven Marissa Farrell Posted July 8, 2016 Marionette Maven Share Posted July 8, 2016 It doesn't really matter in the end, but using the TupleMap is only advanced in the sense that if you were adding vectors or points (i.e. (0,1,2) + (1,2,3)) you'd be adding the independent elements (so the result would be (1,3,5)) If you're only trying to accomplish basic math, it's much easier to just use the + - * / operators. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.