I've been mainly programming PHP, and I recently started with C++.
In PHP the return of a function can be of any type, so you can do checks like this:
public function doSomething()
{
if (! this->userHasAttribute()) {
return false;
}
return "you are logged in.";
}
So basically, if the user would not be logged in doSomething
would return false, else it returns a string.
Since in C++ you return strictly one datatype, how would you approach this?
How to structure those checks/policies, because clearly you dont want to have them inside a function itself (or you will be throwing exceptions everywhere you do a minor check).
Please correct me if I said anything incorrect.
I also came across this post, talking about why the Single Entry Single Exit notion exists in the first place. Someone said that the strongest argument in favor or SESE has vanished.
https://softwareengineering.stackexchange.com/a/118717/269571
A
to check whether a user has been logged in and another function using the result of the functionA
and based on the return value rendering a specific text. Just so you know, the sample code you provided is one of the reasons why people grew to hate PHP, because API of functions was unpredictable and they could return pretty much anything.