Questions tagged [program-flow]
71 questions
                    
                    38
                    
            votes
                
                8 answers
            
        PHP "or" Syntax
I've seen this a lot: $fp = fopen($filepath, "w") or die();
But I can't seem to find any real documentation on this "or" syntax. It's obvious enough what it does, but can I use it anywhere? And must it be followed by die()? Are there any caveats to…
         
    
    
        Andrew
        
- 4,145
- 2
- 37
- 42
                    31
                    
            votes
                
                12 answers
            
        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…
         
    
    
        John Topley
        
- 113,588
- 46
- 195
- 237
                    19
                    
            votes
                
                3 answers
            
        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() {
       …
         
    
    
        gerdemb
        
- 11,275
- 17
- 65
- 73
                    11
                    
            votes
                
                1 answer
            
        Does javascript event handling occur inside or outside the program flow?
This question is related to Javascript event handling and flow control, but it is one step beyond. The question that remains unanswered is: when an event is fired and control is returned to the browser, could the browser decide to handle other…
         
    
    
        Carlo Roosen
        
- 1,025
- 9
- 15
                    6
                    
            votes
                
                2 answers
            
        Should one use `if ($a != NULL)` or `if ($a !== NULL)` to control program flow?
This is perhaps a painfully basic question to answer, but I'm wondering about performance issues regarding using PHP's if identical !== versus if equal != to control flow.
Consider the following trivial PHP function:
        
            
            
                
                    
    
    
         
    
    
                
            
        
    
 
    
    
        msanford
        
- 11,803
- 11
- 66
- 93
                    6
                    
            votes
                
                3 answers
            
        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…
         
    
    
        Ólafur Waage
        
- 68,817
- 22
- 142
- 198
                    5
                    
            votes
                
                2 answers
            
        Do we need to create a error handler for each subroutine?
I copy a piece of code from SO as an example. The subroutine contains an error handler. Should one make an error handler for all Subs?
Public Sub SubA()
  On Error Goto ProcError
  Connection.Open
  Open File for Writing
 …
         
    
    
        lamwaiman1988
        
- 3,729
- 15
- 55
- 87
                    5
                    
            votes
                
                1 answer
            
        How to break out of begin block in Ruby?
How can I break out of the begin block and jump to the rescue block?
def function
  begin
    @document = Document.find_by(:token => params[:id])
    next if @document.sent_at < 3.days.ago # how can I skip to the rescue block here?
   …
         
    
    
        Tintin81
        
- 9,821
- 20
- 85
- 178
                    4
                    
            votes
                
                2 answers
            
        Would this be an example of short circuiting?
If I ask a user to input an int, and need to check if it is within the range of indices of an array before checking the array at that index to see if it's not null, would that be an example of "short circuiting"? Because if the array size is only 5…
        user3059511
                    3
                    
            votes
                
                5 answers
            
        Proper disposal of filestreams and binary streams and disposing of filestreams
As it is, I tried error-proofing my code and ended up making it look quite messy. 
I have a function set up to read a certain type of file. I want the function to return false if there was a problem, or true if everything worked. I'm having trouble…
         
    
    
        mowwwalker
        
- 16,634
- 25
- 104
- 157
                    3
                    
            votes
                
                2 answers
            
        Current possibilities for tracing program flow in C#?
I have used Postsharp a few years ago to trace program flow during execution without needing to manually add trace statements to the methods.
Is there any other new ways to trace execution to to debug output in a similar way?
(Preferably a way that…
         
    
    
        Carl R
        
- 8,104
- 5
- 48
- 80
                    3
                    
            votes
                
                4 answers
            
        Weird bug in Java try-catch-finally
I'm using JODConverter to convert .xls and .ppt to .pdf format. For this i have code something like
try{
    //do something
    System.out.println("connecting to open office");
    OpenOfficeConnection connection = new…
         
    
    
        r15habh
        
- 1,468
- 3
- 19
- 31
                    3
                    
            votes
                
                5 answers
            
        Program flow after an exception is thrown in C#
Hi I'm looking at some old c# code and noticing a lot of code like this:
void SomeFunction()
{
    if (key.Length != Dimensions)
    {
        throw new KeySizeException();
    }
    else
    {
        SomeOtherFunction();
    }
}
I want to know if…
         
    
    
        CodeAndCats
        
- 7,508
- 9
- 42
- 60
                    3
                    
            votes
                
                3 answers
            
        Java Profilers That Display Per Request Statistics and Program Flow
I'm looking for profilers that support per request profiling statistics, ideally along the programs flow (not the usual thread call stack). So basically a profiler call stack + sequential calls view for each single request, something like…
         
    
    
        Elmar Weber
        
- 2,683
- 28
- 28
                    3
                    
            votes
                
                4 answers
            
        try-catch-finally block in java
As per my understanding, I want to follow the best practice for releasing the resources at the end to prevent any connection leaks. Here is my code in HelperClass.
public static DynamoDB getDynamoDBConnection()
{   
    try
    {
        dynamoDB =…
         
    
    
        Chandz
        
- 1,173
- 3
- 18
- 34