Unless and Until in programming languages [closed] - until-loop

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
What is the difference between
if (false == <condition>)
and
if (!<condition>)
and
unless (<condition>)
What is the difference between
while (false == <condition>)
and
while (!<condition>)
and
until (<condition>)
Why isn't unless and until in all programming languages?
Thank you for your help.

if (false == <condition>)
and
if (!<condition>)
and
unless (<condition>)
Logically, they are all equivalent.
Likewise:
while (false == <condition>)
and
while (!<condition>)
and
until (<condition>)
Logically they are equivalent. Except syntactically, until() might be used at the end of a loop and while() at the beginning of a loop.
Although logically they are equivalent, some programming languages provide them (unless, until) for readability.
And you might want to take a look of this to trace back their first usage in programming language.

Related

PostgreSQL - cast to character(1) vs like [closed]

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
What has better (faster) performance?
mycolumn::character(1)='4' or mycolumn like '4%'
where mycolumn is text or character(200)
It is often quite simple to do these tests yourself to see which is faster.
As a general rule, though, like with constants starting the pattern is index-friendly. That means that it would generally be the preferred solution.
Even without an index, like appears to perform better, as this example in db<>fiddle shows. Of course, working on this artificial data does not mean that it would have the same performance characteristics on your data.

Are there other programming techniques? [closed]

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 8 years ago.
Improve this question
I have realized that most of the problems that I solve on a day to day basis are done via two programming techniques: iteration or recursion.
Are there other techniques out there? Any book recommendations or online references?
the programming techniques that you use to solve the problems can be divided into types of algorithms (not into the loop or technique they use in there program, like you mentioned). some of the methods are..
1. Divide and conquer
2. greedy
3. dynamic programming
you can refer this link to read more..

Is it faster to compare or reassign a bool in a loop? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
The question is: is it faster to do that:
if (!self.isStarted)
{
self.started = YES;
}
or simply:
self.started = YES;
and reassign the value at each passing loop.
The conditional is slower, and isn't as clear as simply setting the variable to YES. The point of your code is that you want to ensure the variable is YES after you leave that bit of code, and since the operation is so inexpensive in the grand scheme of things, go for readability, and just set it to YES without checking beforehand.
While a compiler would likely optimize this anyway, self.started = YES; will be faster, because it saves the overhead of having to retreive the value from memory and compare it. This answer is only valid for low-level languages; higher-level languages will be implementation dependent.

PDO prepare statement parameters [closed]

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 just started to learn PDO and i read that in prepare statements you can use named parameters and question marks parameter. So which should i use, or they are completely the same and is just the matter of my decision which to use? Becuase i saw more people choose to use question mark parameters.
As a matter of fact, question marks produce dramatically shorter code.
Being not a novelist but programmer, I prefer concise code like this
$stm = $pdo->prepare("SELECT id FROM table WHERE name=? and pass=?");
$stm->execute(array($name,$pass));
$id = $stm->fetchColumn();
while named placeholders will require me to write every name a dozen times.
But anyway, it's indeed only a matter of personal preference.
You can use both, but using "named parameters" is (for obvious reasons) a lot easier, and more clear.
A good thing about named parameters is that you can see in your code what variable is inserted where in the query, and adding pieces of code (later on) is easier because everything has a name and is not depended on the order of the parameters.

What's the Necessary Items to Document on code? [closed]

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 5 years ago.
Improve this question
There is so many option in each programming languages which can be mentioned in the code documentation.
I want to know what are the most important Items which we have to document?
I'd document contracts (this parameter is expected not to be null, this function never returns null, ...) as well as the meaning (this method does that, ...). Besides documenting the API, I'd add comments on pieces of code which are non-trivial but add a significant value to the application (cryptic but real fast, works around a framework bug).
What you document ultimately depends a lor on who will read that documentation...