Assigning function node variable to incoming payload naming convention

I tend to have my first line in my Blocky nodes as

image

assigning a variable called payload to msg.payload

I then do stuff and quite often just change it to something else and then output it

image

I was idling wondering whether it was a "good idea" to use the same name for the variable as the main msg property

Then I started thinking - what else should I call it - data?

Then I thought, do others follow a convention and if so what is it?

And maybe it would be nice idea if we all used the same one when helping out beginners?

Yes - I'm up early and waiting for a PiZero to update and just had my first drug intake - coffee :slight_smile:

I often go with data to improve readability (payload vs. msg.payload).

For data transformations (resulting in new payload objects) I follow this "pattern":

let data = msg.payload;

// do sth. with data

let result = ...

msg.payload = result;

return msg;

After all, it's all a matter of preference. The important thing is to keep it consistent. :nerd_face:

1 Like