Skip to main content

Questions tagged [control-flow]

Control flow (or flow of control) is the order in which individual statements, instructions or function calls of an imperative program are executed or evaluated.

Filter by
Sorted by
Tagged with
0 votes
2 answers
733 views

Is this a case where 'else' is inevitable?

I am writing some code that enables / disables a certain kind of hardware function. To enable it on, I have to call some methods, and to disable it, some others. Of course I want this code to be clean,...
Bart Friederichs's user avatar
-2 votes
1 answer
270 views

Why is the If-then-else, while loop and for loop a structured programming control structure?

When defining McCabe's essential complexity, the idea of a structured programming control structure is present. I don't understand why an if-then-else, a while loop or a for loop can be reduced to a ...
Cedric Martens's user avatar
0 votes
2 answers
5k views

Creating a control flow graph for a given function

Given is a short Java function and I like to create a control flow graph for it but I'm not sure if it's fine like that? Because I left some things away such as variables that have already been ...
eyesima's user avatar
  • 119
1 vote
1 answer
2k views

How a Control-Flow Graph looks with many (Nested) Functions

From what I can remember the Control-Flow Graphs for which I have seen images have mostly been of single functions. So basically just statements with perhaps looping. But I am wondering what a control-...
HareSurf's user avatar
  • 2,625
20 votes
7 answers
2k views

Should "else" be used in situations where control flow renders it redundant?

I sometimes stumble upon code similar to the following example (what this function does exactly is out of the scope of this question): function doSomething(value) { if (check1(value)) { return -...
rhino's user avatar
  • 357
3 votes
1 answer
2k views

What's the OOP way of dealing with a flow control heavy application?

I'm refactoring a huge WPF application whose complexity stems from the way it deals with flow control. It has a lot of "tiny business rules" that make it really difficult to make a modification ...
Pepedou's user avatar
  • 133
2 votes
1 answer
115 views

How do I achieve non-linear non-dependent control flow using Promises (in server-side ES6)

Coming over from the Java world, I am having trouble translating a multi-threaded approach to IO to the ES6 Promises concept of aysnc IO. Many of the examples I have seen on promises show a linear ...
Michael Plautz's user avatar
2 votes
1 answer
84 views

How to compute whether it is guaranteed the variable is set?

Assuming declarations are expressions consider such code: if ((var x = foo()) and (var y = x)) or (var z = bar()) then println(z); end The reference to x is OK, because at this point x has to be ...
greenoldman's user avatar
  • 1,534
-2 votes
1 answer
349 views

Problem on recursion

void function(int x){ if(x<=0) return; function(x--); } This is a recursion function which is called with the value of x = 20. The Recursive call will take place in this way ...
aswal94's user avatar
  • 11
3 votes
4 answers
2k views

Optimistic & Pessimistic Programming - Ensuring multiple tasks are called only once for specific record

Let's say you have 10 database records which you need to process in the following way: Start Pull 2 records from the database with the 'Processed' flag set to 'false' Call the external web service ...
HABJAN's user avatar
  • 171
3 votes
1 answer
73k views

Flow Chart - While Loops process

I'm having difficulties understanding whether or not this is the right process to use for a flow chart which illustrates the processes involved in an algorithm. For this, assume the following: A 1D ...
Phorce's user avatar
  • 209
0 votes
1 answer
784 views

Control flow testing in white box - static or dynamic?

Yesterday I asked a question that happened to have another meaning inside. I can see that Control/data flow is often mentioned to be static analysis (when tools is used) or dynamic analysis testing in ...
John V's user avatar
  • 4,936
1343 votes
14 answers
273k views

Where did the notion of "one return only" come from?

I often talk to programmers who say "Don't put multiple return statements in the same method." When I ask them to tell me the reasons why, all I get is "The coding standard says so." or "It's ...