Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
How acceptable is to name a variable like that:
int Δt = 3;
and not:
int timeDuration = 3;
I love the Delta character.... However it is only acceptable if this becomes a maintainable standard in your code, so that you or your team knows exactly what it is - and you never mix up notation.
It's likely to work, but I absolutely would not recommend it in anything other than personal projects.
Things like varying encoding languages (UTF etc) can affect these kind of unicode characters. Also the fact it's confusing to reliably type and not really hugely semantic.
Languages such as PHP have these guidelines for vars:
Variable names follow the same rules as other labels in PHP. A valid
variable name starts with a letter or underscore, followed by any
number of letters, numbers, or underscores. As a regular expression,
it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I learned that single equal sign is used to represent 'A is equal to B' rather than double equal sign as in many programming languages.
My understanding about this is single equal sign is usually used to 'assign' operator and double equal sign is used as a substitute to distinguish 'equal' sign from 'assign' operator.
Is there any historical or other reason for this?
SQL is a declarative language, and assignments are not typically made in SQL queries themselves. As a result, SQL doesn't have the problem of ambiguity of = meaning either assignment or equality check. As a result, there is no problem with using = to check equality. On the other hand, in a programming language such as Java, single = is used for assignments, while == is used for comparison.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
This seems like a poor choice since the single quote is such a common character and is hard to see when reading over code.
Was there a reason to pick this over a different sequence or less used character?
How doe we arrived to VB.NET:
BASIC (1964) --> QuickBasic (1985) --> Visual Basic (1991) --> VB.NET (2000s)
In Basic, you could insert a comment by beginning your line with REM (for remark)
REM this is a comment
From QuickBasic, the single-quote was introduced, but REM is still valid nowadays
REM this is a comment
' this is another comment
Why is it like this ? We should probably ask Bill gates and Cie about it.
An assumption would be that :
Double quote character was already used to surround strings in BASIC
Single quote character was not used for anything in BASIC
In Bill's mind, a quote is descriptive enough for a comment, in the sense of "to quote someone"
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
As a developer, a common mistake that I keep on repeating is assuming the data type of a column. I have read multiple articles regarding SQL column naming convention but have not seen any reference regarding data type as part of the column name - specifically for SQL Server.
E.g. Revenue_f for float, Organization_v for varchar, AccountNumber_i for integer and so on.
This must have been thought of already before but I want to know the reason why it is not being used, or an expert's input regarding the matter; pointing me to the right article/documentations will be greatly appreciated.
That is a horrible naming convention. Consider how awful it would be if you need to change AccountNumber to a character datatype. Do you then go back and rename the column and change every single query everywhere? Or do you leave the suffix in your column name even though it is no longer accurate? If you want to know the datatype of a column the ONLY way is to look at the definition of the table.
Also, a single character really is kind of useless. How do you handle nvarchar vs varchar? And what about the scale?
P.S. Even though I wrote an answer I am voting to close this question because it is primarily opinion based and as such is considered off topic for SO.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have a problem writing regular expression. I want to write a regular expression that replaces all double consonants with a single consonant.
Please help me to write such a rule in only one line.
Thanks in advance.
Here's a .NET regex that'll find any group of exactly two non-vowels:
[^aeiou]{2}
The following will work for groups longer than 2:
[^aeiou]{2,}
For example, this will match "llst" in "allstar."
Slightly uglier, but will match groups of 2 consonants, case-insensitive:
[QqWwRrTtYyPpSsDdFfGgHhJjKkLlZzXxCcVvBbNnMM]{2}
The following will match two identical non-vowels:
([^aeiou])\1
For example, this would match the "ll" in "all."
Once you have your regex, just use your chosen language's Regex.Replace function.
Since you did not specify the language, I'm going to go ahead and assume Javascript.
This should get you started:
console.log('babble bubble http htttp www'.replace(/([^aeiou\.,\/=?:\d&\s!##$%^*();\\|<>"'_+-])\1{1}/gi, "$1"));
See more here:
http://regexr.com/3ee47
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want to create a table of vehicles which stores:
Vehicle id
Vehicle name
Vehicle stock
Vehicle condition
Vehicle condition can be "new" or "used".
I do not want to store this field as a String, and I want to avoid making it a Boolean because I would have to make it either is_new or is_old and this approach does not feel satisfying.
Edit: Enum appears to be the ideal solution, however I would still like to know how I would go around adding new conditions if it becomes necessary.
Is there a more expressive way of storing vehicle condition, or will I have to settle for String or Boolean?
Thanks!
I would suggest an ENUM('USED', 'NEW). This defines the different types the value can be, so it's either one or the other, like a boolean, but more expressive.
If new and used are the only two fields, then you could opt for a boolean field. If there was ever a third option, then you should create a table of vehicle condition options. You should also avoid using a column type of enum. There is a performance penalty. The correct approach would be to use a look up table if you have more than 2 options.