Function chaining depending on boolean result
        Posted  
        
            by Markive
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Markive
        
        
        
        Published on 2010-06-07T09:16:38Z
        Indexed on 
            2010/06/07
            11:32 UTC
        
        
        Read the original article
        Hit count: 263
        
This is just an efficiency question really.. I'm interested to know if there is a more efficient or logical way that people use to handle this sort of scenario.
In my asp.net application I am running a script to generate a new project my code at the top level looks like this:
Dim ok As Boolean = True
    ok = createFolderStructure()
    If ok Then ok = createMDB()
    If ok Then ok = createProjectConfig()
    If ok Then ok = updateCompanyConfig()
I create a boolean and each function returns a boolean result, the next function in this chain will only run if the previous one was successful. I do this because an asp.net application will continue to run through the page life cycle unless there is an unhandled exception and I don't want my whole application to be screwed up if something in the chain goes wrong (there is a lot of copying and deleting of files etc.. in this example).
I was just wondering how other people handle this scenario? the vb.net single line if statement is quite succinct but I'm wondering if there is a better way?
© Stack Overflow or respective owner