Click here to Skip to main content
15,891,633 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Rich Shealer21-Dec-21 2:46
Rich Shealer21-Dec-21 2:46 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
David O'Neil21-Dec-21 12:40
professionalDavid O'Neil21-Dec-21 12:40 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:15
James Lonero23-Dec-21 7:15 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Marc Clifton20-Dec-21 8:46
mvaMarc Clifton20-Dec-21 8:46 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Slacker00720-Dec-21 8:54
professionalSlacker00720-Dec-21 8:54 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
trønderen20-Dec-21 12:22
trønderen20-Dec-21 12:22 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Peter Adam20-Dec-21 20:30
professionalPeter Adam20-Dec-21 20:30 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:39
James Lonero23-Dec-21 7:39 
I have learned to agree with you on that. In the old days, I was taught that you write
C++
int f(MyObject obj)
{
    int result = 0;
    MyObject2 obj2 = obj.FunctionA();
    if (obj2 != null)
    {
        MyObject3 obj3 = obj2.FunctionB();
        if (obj3 != null)
        {
            MyObject4 obj4 = obj3.FunctionC();
            if (obj4 != null)
            {
                result = obj4.value;
            }
        }
    }
    return result;
}

Now I find it easier to understand when I write
C++
int f(MyObject obj)
{
    MyObject2 obj2 = obj.FunctionA();
    if (null == obj2)
    {
        return 0;
    }

    MyObject3 obj3 = obj2.FunctionB();
    if (null == obj3)
    {
        return 0;
    }

    MyObject4 obj4 = obj3.FunctionC();
    if (obj4 != null)
    {
        return 0;
    }

    result = obj4.value;
}

This is easier to understand than having the code march off the right side of the page and removes exceptions to normal processing early on without cluttering the main part of the code. Since I write software application applications, I'm normally have these types of code where
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
James Lonero23-Dec-21 7:12
James Lonero23-Dec-21 7:12 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Gary R. Wheeler20-Dec-21 7:14
Gary R. Wheeler20-Dec-21 7:14 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Slacker00720-Dec-21 8:59
professionalSlacker00720-Dec-21 8:59 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Leo5620-Dec-21 23:57
Leo5620-Dec-21 23:57 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
dan!sh 20-Dec-21 22:11
professional dan!sh 20-Dec-21 22:11 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
MadGerbil21-Dec-21 1:47
MadGerbil21-Dec-21 1:47 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
rjmoses21-Dec-21 10:51
professionalrjmoses21-Dec-21 10:51 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
rjmoses21-Dec-21 10:54
professionalrjmoses21-Dec-21 10:54 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
englebart21-Dec-21 13:05
professionalenglebart21-Dec-21 13:05 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Ryan Peden21-Dec-21 17:48
professionalRyan Peden21-Dec-21 17:48 
GeneralRe: Expression bodies vs Good Old Fashioned Functions Pin
Matt McGuire22-Dec-21 6:01
professionalMatt McGuire22-Dec-21 6:01 
GeneralRe: CCC 20-12-2021 - Solution Pin
pkfox20-Dec-21 2:11
professionalpkfox20-Dec-21 2:11 
GeneralRe: CCC 20-12-2021 - Solution Pin
OriginalGriff20-Dec-21 2:17
mveOriginalGriff20-Dec-21 2:17 
GeneralRe: CCC 20-12-2021 - Solution Pin
pkfox20-Dec-21 3:14
professionalpkfox20-Dec-21 3:14 
GeneralRe: CCC 20-12-2021 - Solution Pin
OriginalGriff20-Dec-21 3:30
mveOriginalGriff20-Dec-21 3:30 
GeneralRe: CCC 20-12-2021 - Solution Pin
Rich Leyshon20-Dec-21 2:40
Rich Leyshon20-Dec-21 2:40 
GeneralRe: CCC 20-12-2021 - Solution Pin
OriginalGriff20-Dec-21 3:11
mveOriginalGriff20-Dec-21 3:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.