program-flow

How is GUI and Game Program Flow compared to Web programs

I've been developing Web applications for a while now and have dipped my toe into GUI and Game application development. In the web application (php for me), a request is made to the file, that file includes all the necessary files to process the info into memory, then the flow is from Top to Bottom for each request. (mainly) I know tha...

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 to stop the code parsing. I run the code parsing in a background worker. I want to be a...

Interupting program flow in C

Okay, here's my problem: I've got a loop running that increments the value of a variable each iteration, and I want to be able to hit a key on the keyboard to stop the loop and report the final value of the variable. Thing is, I can't figure out how to do this in C. I feel stupid because it seems like I'm overlooking some really simple a...

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 name of the function the class name that owns that method or function Is it possible to...

How do i make the mutex not be recusive?

I ran the code below expecting flow to be locked on the 2nd time i lock a mutex. After running it twice i realize it can lock many times (assuming in the same thread) without stopping. How do i change this behavior? using System; using System.Collections.Generic; using System.Text; using System.Threading; namespace Test { class Pr...

Should I use early returns in C#?

I've learned Visual Basic and was always taught to keep the flow of the program without interruptions, like Goto, Exit and Return. Using nested ifs instead of one return statement seems very natural to me. Now that I'm partly migrating towards C#, I wonder what the best practice is for C-like languages. I've been working on a C# project...

confirming program flow

can someone tell if the code below would work fine? class CriticalSection{ int iProcessId, iCounter=0; public static boolean[] freq = new boolean[Global.iParameter[2]]; int busy; //constructors CriticalSection(){} CriticalSection(int iPid){ this.iProcessId = iPid; } int freqAvailable(){ for(int i=0; i< Global.iParameter[2]; ...

Accessing the containing class of an inner class in Java

This is what I'm doing now. Is there a better way to access the super class? public class SearchWidget { private void addWishlistButton() { final SearchWidget thisWidget = this; button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // A better way to access th...

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; } public static void main(String[] args){ Example e = new Example(5); What ...

Programming style: should you return early if a guard condition is not satisfied?

One thing I've sometimes wondered is which is the better style out of the two shown below (if any)? Is it better to return immediately if a guard condition hasn't been satisfied, or should you only do the other stuff if the guard condition is satisfied? For the sake of argument, please assume that the guard condition is a simple test th...

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 up for further connections. That socket communication system is contained in a class. ...

routing mvc on the web

Hi, I was wondering if anyone could possibly provide me some advice on how i could improve the routing (and/or architecture) to each 'section' of my application. (I'm writing in PHP5, and trying to use strict MVC) Basically, I have a generic index page for the app, and that will spew out boilerplate stuff like jquery and the css etc. ...

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 = flag2 conditions I have to make sure is that flag is false when the script is cal...