You need to sign in to do that
Don't have an account?
Style question
So I am new to apex and salesforce and I have been going through a lot of apex. I know all you experienced devs just cringed a little lol, dont wory I am not modifying anything. Anyway, the code I am looking at is very sloppy from a styling standpoint. There appears to be no structured way that the coders have stuck to in order to make the code easily readible. There is no consistant use of tabbing or even consistancy in the amount of whitespace between words or blocks. So I have also see, and this is the point of the post, a lot of lines that run on and on. All the code in the first example is shown below EXCEPT it is all one line. So in order to see it you would have to horizontally scroll quite a bit.
BusinessHours bHr = [Select b.WednesdayStartTime, b.WednesdayEndTime, b.TuesdayStartTime, b.TuesdayEndTime, b.TimeZoneSidKey, b.ThursdayStartTime, b.ThursdayEndTime, b.SystemModstamp, b.SundayStartTime, b.SundayEndTime, b.SaturdayStartTime, b.SaturdayEndTime, b.Name, b.MondayStartTime, b.MondayEndTime, b.LastModifiedDate, b.LastModifiedById, b.IsDefault, b.IsActive, b.Id, b.FridayStartTime, b.FridayEndTime, b.CreatedDate, b.CreatedById From BusinessHours b WHERE b.IsDefault=true AND b.IsActive = true LIMIT 1];
My question is, can a newline be entered after the comma that separates the fields in the query? I do not have the ability to test it for myself so I wanted to turn to you guys for assistance.
Yes.. no problems.
All Answers
Yes.. no problems.
In this particular query, the 'b.' notation provides no additional documentation value;
I also tend to order my fields alphabetically when there are long lists of fields as in
Thanks for the replies guys.
The aliasing is automatically added to the query if it is built in the Force.com IDE. I was also curious why it was used, then went into the ide and built a few queries and noticed it automatically does it.