Questions tagged [program-flow]
71 questions
3
votes
1 answer
OOP design: How to decide program flow and class responsible for method (JSFML library)
I'm designing a 2D game to practice Java and Object Oriented Programming (I'm using the JSFML library, if that helps), and I have doubts regarding how to best design the following:
The library I'm using offers a Drawable interface implemented by…

Leandro Nogueira Couto
- 177
- 1
- 1
- 9
3
votes
5 answers
controlling program flow without if-else / switch-case statements
Let's say I have 1000 functions defined as follows
void func dummy1(int a);
void func dummy2(int a, int aa);
void func dummy3(int a, int aa, int aaa);
.
.
.
void func dummy1000(int a, int aa, int aaa, ...);
I want to write a function that takes an…

bfaskiplar
- 865
- 1
- 7
- 23
3
votes
5 answers
How to find out who is the caller of a method or function?
I want to write a debug function or method that will help print useful information. When it is called, I need:
the memory address of the calling object (if called by an object)
the method signature of the caller (or the name of the method), or the…
HelloMoon
3
votes
0 answers
How to use NCC (nccgen/nccnav)?
I'd like to understand how to use a tool called NCC:
http://students.ceid.upatras.gr/~sxanth/ncc/
Its purpose is to detail program call graph and internal symbol dependencies, similar to cflow/cscope. But I can't get it to work.
I've cloned a git…

rostamn739
- 323
- 3
- 8
2
votes
5 answers
How do I understand a function that returns a function?
Here's the example code I'm struggling with:
function greaterThan(x) {
return function(y) {
return y > x;
};
}
var greaterThanTen = greaterThan(10);
show(greaterThanTen(9));
Is there a way to put it in math terms or follow the flow or…

Wolfpack'08
- 3,982
- 11
- 46
- 78
2
votes
0 answers
Haskell Twitch Library not working as expected
I am playing around with the Twitch library:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Twitch
import Data.Default
import Turtle.Prelude
import RIO
main :: IO ()
main = do
print "hi"
…

Fabian Schneider
- 799
- 1
- 13
- 40
2
votes
4 answers
Writing redundant program flow statements for clarity or optimization reasons?
I am tagging this as C, though it certainly applies to many languages. The reason for this is the part of the question dealing with optimization, which is compiler dependent.
Sometimes we encounter situations like this in programs:
if(bob == 42)
{
…
user1481860
2
votes
6 answers
How should I format this piece of code?
Here are two ways of calling callscript (in pseudocode):
using duplicate calls
if flag == true
flag = false
callscript
flag = true
else
callscript
endif
using an extra variable
flag2 = flag
flag = false
callscript
flag =…

Lazer
- 90,700
- 113
- 281
- 364
2
votes
5 answers
C++ Program Flow: Sockets in an Object and the Main Function
I have a rather tricky problem regarding C++ program flow using sockets.
Basically what I have is this: a simple command-line socket server program that listens on a socket and accepts one connection at a time. When that connection is lost it opens…

jstm88
- 3,335
- 4
- 38
- 55
2
votes
12 answers
Java language convention; getters/setters
Public class Example {
private int number;
public Example(int number){
this.number = number;
}
public int getNumber(){
return number;
}
public void setNumber(int number){
this.number = number;
…

Skogen
- 721
- 1
- 11
- 30
2
votes
4 answers
Deciphering large program flow in Python
I'm in the process of learning how a large (356-file), convoluted Python program is set up. Besides manually reading through and parsing the code, are there any good methods for following program flow?
There are two methods which I think would be…

Ross Aiken
- 912
- 1
- 6
- 16
2
votes
4 answers
Using exceptions to control program flow
Let me give you an example. I have the following web method inside my aspx.cs file which I use for AJAX calls:
[WebMethod]
public static ResponseMessage GetNextQuestion(string quizGuid)
{
using (DbEntities db = new DbEntities())
{
…

anar khalilov
- 16,993
- 9
- 47
- 62
2
votes
2 answers
Java: why is this code not working? Infinite loop?
So as you may be able to tell from my attempt, I'm trying to figure out how I'd make a program which gives the user 5 seconds to enter some lines of text, then the Scanner will count how many lines were entered. I've just started learning Java as my…

Sam
- 97
- 2
- 4
- 11
1
vote
4 answers
Creating a cancel scheme
I have a program that will analyzes source code. It can recursively go through a directory to find all projects, and then recursively go through the project to find all source code.
I want to create a cancel process button, which allows the user…

Dan McClain
- 11,780
- 9
- 47
- 67
1
vote
1 answer
Trouble with program flow
I am somewhat of a novice at Swift, and am having a difficult time understanding the logical flow in which things are being processed. There are a couple of things in my program that seem to be running in a sequence that I'm not expecting, in
In…

Gary Jones
- 11
- 1