Questions tagged [conditions]
The conditions tag has no summary.
131 questions
18
votes
7
answers
4k
views
Is there a reason "replace conditional with table" isn't a standard refactoring?
I'm preparing a lecture where I will start with a many-branched conditional statement and replace it with a table. For example, I could start with:
function getMonthName(monthNumber) {
if (...
19
votes
7
answers
5k
views
Debugging a performance issue, do I commit the timing code?
I am working in small company, having a lead position in a group of 5. We are developing a C++ application. One requirement is that it needs to run fast.
Today, I noticed one function, say f1(), and ...
1
vote
1
answer
336
views
Could conditions be used with Data Flow Diagrams?
I'm trying to make a DFD for this scenario:
after admission, the patient gets the service he needs.
I've been trying to do it using this diagram (there are 3 available services):
but I don't think it'...
5
votes
5
answers
1k
views
Is it bad practice to use nullptr in ternary operation?
I've set up a ternary operator in place of a pile of if-else's, the final expression being nullptr in order to finish the loop, like so:
int menuSelect;
std::string operation="";
(...
0
votes
4
answers
221
views
Should we create a new function for every multiple conditions?
I have the existing code provided below:
if (!$existing_records && !$has_required_field) {
return 'Skip Update, no records found';
} elseif (!$existing_records && $...
0
votes
2
answers
179
views
Where to check preconditions in multi functions
In a library, there could exist three types of functions. The first are those which are visible to the user i.e. their declarations are installed in the library's include directory. The third are ...
0
votes
1
answer
215
views
Many if conditions
I have the code but I want to be pseudo as possible so I learn from other ways as much as possible.
So what I am building is web based tool and in one section we have a table.
This table renders lines ...
4
votes
2
answers
363
views
How to structure many complex conditionals on a class
I have a class (as a protobuf) OrderChange, that represents when an order (imagine Amazon.com) changes:
message OrderChange {
Order old_order = 1;
Order new_order = 2;
}
message Order {
...
2
votes
1
answer
3k
views
Multiple if condition optimization
Often I find conditional statements such as:
if (life_max < max):
if (expand):
do life_max = max
else:
if (life_max > max) and not (expand):
do life_max = max;
Although readable, ...
3
votes
4
answers
833
views
Is the strategy pattern for 3 variants overuse?
I am curious about it because I talked with a friend about the strategy pattern, and we diverge about when we have to use it.
Our scenario is that I have to build a view component with 3 variants. All ...
2
votes
1
answer
297
views
What is the name of this pattern / style?
We have a "workflow orchestration" system at work.
It works something like this:
You configure what to run (in a database table), such as:
NameOfStepATHingToRun ="weather_data"
...
3
votes
0
answers
103
views
Refactoring nested if-else statement [duplicate]
I have an app where every object is checked based on various types of business rules. For this, i used multiple nested if-else statement which was done in one class. I am not happy with this situation ...
3
votes
1
answer
4k
views
Why does a condition variable's wait() release the associated mutex before blocking and reacquire it before returning?
Stallings' Operating System book says about condition variable in Solaris,
A condition variable is used to wait until a particular condition is
true. Condition variables must be used in ...
-2
votes
1
answer
817
views
Refactoring nested if-else interface method in Java8
I have the below default method in an interface and it seems to be pretty complex because of the many if-else conditions.
default void validate() {
Application application = application().get();
...
-2
votes
1
answer
981
views
Conditional command pattern
I have an abstraction that defines something like a command pattern,
interface Participant {
void proceed();
}
Participants are grouped in a collection and are called all together. But each ...