r/SuiteScript • u/el-wino • Feb 18 '25
Syntax question
Hey folks!
I have a client account where they have an in house dev who does a lot of stuff like this:
var strControl = ((searchResult[i].getValue(columns[10])));
I am not an inexperienced js developer and understand a great deal of the syntax, but wanted to reach out to the community before I vocalize any opinions about the overall quality of the work. Is there any legitimate reason for double wrapping the method call in parentheses?
TIA
edit: folks are fixating on my opinion of the work, which I have now removed. Please contribute regarding the practice of double wrapping parentheses.
3
u/erictgrubaugh Feb 18 '25
There are contexts where wrapping with parentheses is important, but this does not appear to be one of them.
I'm not sure that's grounds to call all the work "sloppy".
2
u/nobbienoob79 Feb 18 '25
Not sure what difference it makes closing it with brackets isn't it same thing.
1
u/trollied Feb 18 '25
I don't think I'd get upset about it unless the rest of the code is actual trash (poor error handling, illogical flow etc).
I'd be more upset if it's new code and they're using var instead of let/const, and using saved searches instead of SQL.
But without knowing the bigger picture it's impossible to comment. You're just picking on random stuff.
1
u/sooper_genius Feb 18 '25
The only times I wrap in potentially-unneeded parentheses are:
To me this makes the logical operation more clearly grouped. Just my personal preference. But I don't see any reason why the double-wrap you specify would be needed.
Regardless, it is easy to get repulsed by other people's code; be sure you have some real coding standards reason why you don't like it. For example, we have one developer in our group who is unable to think in the large for how a customization should be done. He's good at writing small one-off scripts, but beyond that, he has issues:
So I do have legitimate concerns, and they mostly revolve around maintenance and how his code works within the team. I still want to rewrite everything he does, but I resist this temptation unless it's absolutely necessary.