Re: Optimization in coding style



One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Geoff Muldoon's handwriting:

> My preference is to use single quotes unless you are certain that the
> string will surely have an apostrophe, and then decide whether it will
> be better to escape the apostrophe or switch to double quotes.

Agreed.

>> Double quotes are needed, of course in other cases:
>> "Frankly my dear, your name is ${nameOfTheUser}!"
>
> No they're not, and my strongly preferred style is to clearly string
> escape and concatenate variables. For starters in my editor it is far
> superior for syntax highlighting and debugging, even if it is more
> typing:
>
> $string = 'My "nickname" is '.$myNickName.', what\'s yours?';
>
Hmmm... I'd say that it's a definetely less readable than:
$string="My \"nickname\" is $myNickName, what's yours?";

and if you can use single quotes to surround "nickname":
$string="My 'nickname' is $myNickName, what's yours?";

I really like to write readable code. Saves time and hassle.

Besides, don't know about yours, but my editor highlights the variables
surrounded by double-quotes as viariables.

Cheers
Mike
.



Relevant Pages

  • Re: Backup Script
    ... preference. ... Note those are back ticks around the entire date string, ... single quotes inside. ...
    (alt.os.linux)
  • Re: Which is correct?
    ... it just a matter of preference. ... single quotes are handy when ... or if the javascript outputs html which contains quotes. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Hyperlink function fails when using variable row number
    ... It mitght be noted that if you just have one word for the sheet name and ... surround it by single quotes like you would if you had two or more words ... that the single quotes will disappear automatically. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: return table and count with sp_msforeachtable
    ... And to include it in the result set, surround the parameter with double ... single quotes. ... Bern ... >> I ran the following query and I got a count for every single table in my ...
    (microsoft.public.sqlserver.programming)
  • Re: Double Quote (") in String
    ... The \" escape sequence is just for C# code. ... simplest answer for you is to use single quotes to surround your value, ...
    (microsoft.public.dotnet.framework.aspnet)