List of things I shouldn't do because soft says so

Discussions concerning programming of SOFTIMAGE©
iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

List of things I shouldn't do because soft says so

Post by iamVFX » 22 Jan 2013, 12:45

[rimg=900]http://i.imgur.com/cg5kPYb.png[/rimg]

Is there a full list of things I can't do? Like passing Python dictionary as return object?

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: List of things I shouldn't do because soft says so

Post by xsisupport » 22 Jan 2013, 13:31

Commands have some private arguments. Name is apparently one of them.

In JScript, you get this error:

Code: Select all

// ERROR : 2299 - This command argument already exist and cannot be used: Name
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 22 Jan 2013, 13:41

xsisupport wrote:Commands have some private arguments. Name is apparently one of them.
Yea, would be cool if I would know that before I spend half an hour to figure out what caused it (sometimes the error is not show up)

Is there a full list of private arguments anywhere?

Btw, I thought name and Name are two different variables :-??
Last edited by iamVFX on 22 Jan 2013, 13:45, edited 1 time in total.

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: List of things I shouldn't do because soft says so

Post by xsisupport » 22 Jan 2013, 13:45

iamVFX wrote:
xsisupport wrote:Commands have some private arguments. Name is apparently one of them.
Yea, would be cool if I would know that before I spend half an hour to figure out what caused it (sometimes the error is not show up)

Is there a full list of private arguments anywhere?
No. But iirc, any other private arguments are those used by builtin commands that are implemented by scripts. Those command have private arguments to specify the script engine and the handler proc in the script file.
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 13:31
Skype: csaezmargotta
Location: Sydney, Australia

Re: List of things I shouldn't do because soft says so

Post by csaez » 25 Jan 2013, 03:04

Hi,

Maybe this is an obvious reply but I highly recommend work with a coding convention.
I usually add a prefix to my variables indicating the data type (i.e. sName, oObj, lItems) and a "p_" if it's a parameter (i.e. p_sName, p_oObj, p_lItems). The same is true for command names, a lot of people add a prefix indicating the author/company name.

A coding convention will make your tools a lot easier to debug/maintain and you probably won't have name collisions never again, just pick one and start using it :)

Cheers!

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 25 Jan 2013, 07:11

csaez wrote:Hi,

Maybe this is an obvious reply but I highly recommend work with a coding convention.
I usually add a prefix to my variables indicating the data type (i.e. sName, oObj, lItems) and a "p_" if it's a parameter (i.e. p_sName, p_oObj, p_lItems). The same is true for command names, a lot of people add a prefix indicating the author/company name.

A coding convention will make your tools a lot easier to debug/maintain and you probably won't have name collisions never again, just pick one and start using it :)

Cheers!
I use different naming convention which is called obvious naming. When your object is named obviously, like size, deformer or path, you know that size holds number, deformer is an object and path is a string. It doesn't matter if number is an integer or float or double in dynamically typed language. For scripting purposes in Softimage it's more than enough, most of the time you deal with objects and if you need their name you call its property.

What bother me is that, as you mentioned, if you are a experienced C++ developer and you should care which type of the object you're holding, why the hell you call private class variable name? Good to read

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 13:31
Skype: csaezmargotta
Location: Sydney, Australia

Re: List of things I shouldn't do because soft says so

Post by csaez » 25 Jan 2013, 08:17

It's not always so obvious, depends a lot on context and your personal perception (path could be a curve and deformer an operator in a rigging context).
Coding conventions are all about readability :)

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 25 Jan 2013, 11:42

csaez wrote:It's not always so obvious, depends a lot on context and your personal perception (path could be a curve and deformer an operator in a rigging context).
Context is given by a function or class you're dealing with.

Code: Select all

def ExportObj( object, path ):
    ...
You don't expect a curve named path

If you want to hold operator in a path variable, for me, personally :) , path_operator is more intuitive and readable than opPath or pathOp

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 25 Jan 2013, 12:14

But even I, not-that-great-"coder", know that private variable name should be prefixed with underscore. [-(

Image

Those are just lame design decisions.

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 30 Jan 2013, 10:12

Image

**==

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 31 Jan 2013, 22:02

Image

(%)

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 00:41

Re: List of things I shouldn't do because soft says so

Post by EricTRocks » 01 Feb 2013, 00:23

I'm really confused by this thread and don't really see the validity of it other than a place to post things that you run into that are frustrating (Something that may be better suited for a blog?). Is there any details you can provide to some of these posts such as repro steps so that the thread could take a productive turn into helping identify some issues within Soft?
Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 01 Feb 2013, 06:18

EricTRocks wrote:Is there any details you can provide to some of these posts such as repro steps so that the thread could take a productive turn into helping identify some issues within Soft?
Sure

Image

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 01 Feb 2013, 06:48

I'm excited to see the ugliness of workarounds which can be suggested :D

(actually, comparing nested curve objects before and after the command is not that ugly, but it is still a workaround and definitely not OO way of doing it)

iamVFX
Posts: 697
Joined: 24 Sep 2010, 16:28

Re: List of things I shouldn't do because soft says so

Post by iamVFX » 07 Feb 2013, 15:15

[rimg=900]http://i.imgur.com/SUkDEVB.png[/rimg]

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 00:41

Re: List of things I shouldn't do because soft says so

Post by EricTRocks » 07 Feb 2013, 15:20

I don't believe that XSI commands can return python objects such as lists. Could you create a collection and fill it with your items then return that instead?
Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken