Please do not use "type" as a function parameter name...

Please do not use "type" as a function parameter name...like:

function Map:getObjectsWithType(type)

as this will hide the system function type() within the scope of that function, which could lead to obscure bugs or crashes.

I just got bitten when I tried to add an extra test like if(type(ob=="string") inside one of those functions, and it took me a while to figure out what was wrong and started seriously to doubt my own sanity before I finally found it... not sure about my sanity, but I am sure about the recommended best practice ;-)

The following function currently use type as a function parameter:

function Map:getObjectsWithType(type)
function Map:firePropertyListener(property, type, object)
function ObjectLayer:getObject(name, type)
function ObjectLayer:getObjects(name, type)
function ObjectLayer:getObjectsOfType(type)

Maybe use "atype" instead of "type" (?)

-FrankS

Ah dang, good catch there again, sorry about causing you to doubt your sanity. I have the luxury of losing mine ages ago so my mind is free from any doubt.

How about "objectType" and "propetyType" ?

anything but "type" will do ;-)

... but personally I do like the more expressive, somewhat longer variable names as then you do not have to guess too much, so your suggested names would do exactly that.

All changed. I usually am more of a fan of the more expressive names too. I blame uni for having the shorter names.

views:1423 update:2011/10/13 16:30:09
corona forums © 2003-2011