re: What are your thoughts on functional programming? In PHP? VIEW POST

re: So think about a function isLoggedIn($loggedIn). You'll have to continually pass in $loggedIn everywhere. To write isLoggedIn() functionally, you w...

So, OOP architecture wants us to abstract isLoggedIn() away from the rest of the application. That way we don't have to write redundant code like

$user = User::getUser();

To me, it is much more efficient for me to go to one place to understand where the user is logged in. Rather than having to resolve a bunch of dependencies before I can know if my user is logged in. Example:

What if the system were setup in a way where the user being logged in needed more data than just the user object. For example, they also needed a cookie and a line in the database that says they are logged in. To keep my isLoggedIn() function in the FP paradigm I would then need to do something like this:

$user =
$cookieValue =
$databaseValue =
isLoggedIn($user, $cookieValue, $databaseValue);

Now instead of just getting a user, I need to get the cookie and the db value. ALL just so I can write my functions in the FP paradigm.

Code of Conduct Report abuse