I need javascriptGuru for a good-looking code.

Nov 19, 2008 at 7:37am

I need javascriptGuru for a good-looking code.

Hello maxers,

I learn alone maxMsp. I’m not a genius in coding, i’m a cook. Here a question, stupid (i have severals like that), but :

i often declare variable to clear up the code :

function toto (a,b,c)
{
var k = Math.floor(a/340);
var l = Math.floor(b+54);
var m = Math.floor(c/32);
return (k, l, m) ;
}

instead of :

function toto (a,b,c) {
return (Math.floor(a/340), Math.floor(b+54), Math.floor (c/32));
}

do you think it’s a bad habit ? is it heavy for memory allocation (with hundreds of function) or is it just insignificant for modern computer.

I can’t find answer in books, so any wise man ?

thanks, ciao.

#40921
Nov 19, 2008 at 8:00am

On 19 nov. 08, at 08:37, nicolas wrote:

> do you think it’s a bad habit ? is it heavy for memory allocation
> (with hundreds of function) or is it just insignificant for modern
> computer.

IMHO when you write code, it’s a better habit to make your code
readable. If you have performance issue, you can optimize later.

ej

#145245
Nov 19, 2008 at 8:02am

Hi Nicolas,

That’s not a bad habit, it’s preferable in terms of readability that
you do so — essentially, 4 months from now when you go back to make a
change in your code it’ll be easier to read and to figure out what you
were thinking at the time.

The impact on the computer isn’t going to be that big as after the
function completes execution those variables will be cleaned up
automatically so they don’t accumulate over time.

-n

On Nov 18, 2008, at 11:37 PM, nicolas wrote:

>
> Hello maxers,
>
> I learn alone maxMsp. I’m not a genius in coding, i’m a cook. Here a
> question, stupid (i have severals like that), but :
>
> i often declare variable to clear up the code :
>
> function toto (a,b,c)
> {
> var k = Math.floor(a/340);
> var l = Math.floor(b+54);
> var m = Math.floor(c/32);
> return (k, l, m) ;
> }
>
> instead of :
>
> function toto (a,b,c) {
> return (Math.floor(a/340), Math.floor(b+54), Math.floor (c/32));
> }
>
> do you think it’s a bad habit ? is it heavy for memory allocation
> (with hundreds of function) or is it just insignificant for modern
> computer.
>
> I can’t find answer in books, so any wise man ?
>
> thanks, ciao.
>

#145246
Nov 19, 2008 at 5:09pm

#145247

You must be logged in to reply to this topic.