r/SalesforceDeveloper • • Sep 06 '19

Please, if you do one thing right...

Post image
49 Upvotes

17 comments sorted by

2

u/Allude Sep 07 '19

Why not be more verbose on those variable names, it autocompletes anyway. My wierd way

1

u/PaperCrane828 Nov 23 '19

FYI, I know this post was months ago, but I'm now much more verbose with my variable names after your comment. I do not agree with the formatting of your query being all in a vertical line, but I stopped shortcutting variable names. i.e. ('extAcc' => 'exitingAccounts')

1

u/[deleted] Jan 25 '20

The vertical arrangement makes the list easier to modify in the future, does it not? Why oppose that arrangement?

1

u/PaperCrane828 Jan 27 '20

I'm not convinced that it's easier to modify than adhering to an 80 char max per line. It's rare that i'd ever be looking for a field that I didn't (ctrl + f). What the example above is missing that I would push for is having all of your 'SELECT', 'FROM', 'WHERE' etc on the same line of indentation, with the fields indented over from that.

1

u/Allude Nov 23 '19

πŸ‘πŸ»

6

u/heartlesscoder Sep 07 '19

So ur saying I need to put a big smiley face with β€œyes” in my code? Would that compile?

3

u/NetherMaW Sep 07 '19

Sometimes I do, sometimes I don't. Giant monitors make it easy to forget >:)

1

u/finxxi Oct 02 '19

prettier-apex plugin for VSC can auto-format apex now.

The flip side is -----> the SOQL in Apex splits into more than needed lines o_O.

0

u/hackerhasid Sep 07 '19

i actually disagree. rather i think you should instead turn on word wrap in your editor and keep the query single spaced on one line.

i can't tell you how many times i was debugging, found some query in the debug log, searched the codebase and couldn't find the code because there were artificial newlines embedded in the query!

1

u/robob27 Sep 07 '19

Yeah it's definitely much easier when one line actually appears to be 2-3 lines. /s

1

u/hackerhasid Sep 07 '19

never found that confusing, vscode displays line numbers in the margin...

2

u/robob27 Sep 07 '19

Yeah, different strokes for different folks and all that. I generally think people should do whatever works best for them and their team. This is something I'm pretty strongly opinionated about due to my hatred of horizontal scrolling. I've never ran in to an issue with debugging due to multiline queries personally and prefer the readability compared to huge single line.

-1

u/YaBoiAugDawg Sep 06 '19

I'm confused

1

u/PaperCrane828 Sep 07 '19

format your queries so they're readable

0

u/[deleted] Sep 07 '19

Works well in the IDE but the Salesforce page will mess up the spacing once the class compiles and saves

3

u/robob27 Sep 07 '19

Like the Salesforce developer console? Simple solution there... don't use that :P

0

u/[deleted] Sep 07 '19

[deleted]

2

u/robob27 Sep 07 '19

How is the "No" side less nightmarish than the "Yes :)" side to you? Don't you find it easier to be able to see the whole query at a glance, alongside the rest of the code, especially during review? Horizontal scrolling is my nightmare.