The conditions tag has no wiki summary.
6
votes
7answers
992 views
Making Simple IF Statements Shorter
If we assume we have this little snippet of code:
string str = "checked";
bool test1;
if (str == "checked")
{
test1 = true;
}
else
{
test1 = false;
}
Is it bad practice to change a simple ...
2
votes
3answers
141 views
Conditional construct for a kleenean data type
I was thinking of an hypothetical programming language with a kleenean data type which would implement Kleene's three-valued logic. To sum up, it's an extension of the boolean data type with the three ...
-1
votes
2answers
147 views
Boolean-Integer Typecasting to Replace Conditional
When choosing a value based off of 2 boolean values in this format
var foo:int;
if (X){
foo = 50;
} else if (Y){
foo = -50;
} else {
foo = 0;
}
I discovered that I can condense this ...
6
votes
3answers
229 views
Approaches to checking multiple conditions? [duplicate]
What is the best practice for checking multiple conditions, in no particular order?
The example in question needs to check four distinct conditions, in any order, and fail showing the correct error ...
1
vote
1answer
280 views
Condition coverage for If(A && B) - measuring the input or code exercised?
I have been studying condition coverage for last few days. In a book "The Art of Software Testing" they highlight that it does not assure decision coverage, because for example
IF(A && B)
...
0
votes
4answers
174 views
How to count condition coverage
I am wondering, What would be the correct condition coverage test cases for the following condition:
if(A && E && (B || C || D))
Considering short circuiting, what cases would I ...
-1
votes
1answer
75 views
Automation Approaches: Events/Triggers/Cron [closed]
It has been my experience, when building websites, that most of the logic of a system is executed when user input is accepted, be it via POSTs, GETs etc. I would like to know what processes or ...
5
votes
4answers
545 views
Differences in If… Else… statement
When I first started to learn programming I remember having an argument with my teacher about If Else statements. I was arguing that:
if {
...
} else if {
...
} ...
is basically the ...
-2
votes
3answers
301 views
Should I use AND or should I use OR [closed]
An order can be in the "status" of Completed, Corrected or some other status.
I saw some code that is checking it like this, the purpose is to disable some stuff when the status is in Completed or ...
34
votes
7answers
2k views
How can I reformat my condition to make it better?
I have a condition
if(exists && !isDirectory || !exists)
{}
how can I modify it, so that it may be more understandable.
29
votes
10answers
3k views
Why do we have to use break in switch
Who decided, and basing on what concepts, that switch construction (in many languages) has to be, like it is? Why do we have to use break in each statement? Why do we have to write something like ...
6
votes
3answers
756 views
What is the difference (if any) between (null != $object) and ($object != null) when using PHP?
I am used to Java and therefore always think conditions are interpreted from left to right, i.e. there is a vital difference in null != $obj and $obj != null
Now this seems not to be the case with ...
1
vote
3answers
125 views
Conditional checks against a list
I was wondering how computers do this.
The most logical way I can think is that they are iterating trough all elements of the list until they find one that matches the condition :)
For example if ...
7
votes
5answers
384 views
What should developers test before submitting their work to testers?
Is there a checklist the developer must go over before passing their work to testers ?
Also, what are the conditions/cases the developer must pay attention to ?
8
votes
4answers
644 views
Is the use of explicit ' == true' comparison always bad? [duplicate]
Possible Duplicate:
Make a big deal out of == true?
I've been looking at a lot of code samples recently, and I keep noticing the use of...
if( expression == true )
// do something...
...
3
votes
1answer
88 views
Getting your user agreement right
I'm planning to provide a little service with which you can control your computer from anywere. It exists out of a server (which I will be providing), and two clients (a controlled one and a ...
54
votes
34answers
8k views
Ternary operator considered harmful? [closed]
For example, would you prefer this one-liner
int median(int a, int b, int c) {
return (a<b) ? (b<c) ? b : (a<c) ? c : a : (a<c) ? a : (b<c) ? c : b;
}
or an if/else solution ...
10
votes
8answers
560 views
Most readable way to format long if conditions?
Long winding if conditions should be avoided if at all possible, yet sometimes we all end up writing them. Even if it's a very simple condition, the involved statements are sometimes simply very ...