bobmagicii, (edited )
@bobmagicii@phpc.social avatar

bigger this app gets the more im considering switching to a null object approach. but the only people i've ever known using it were canadian 🤣

"dont check if exists and is an instance. know it is an instance. it just happens this instance has id of 0 and email of null."

a: if($User && $User->IsAdmin())

b: ($User->IsAdmin())

a: if($User) ShowTools();

b: if($User->ID !== 0) ShowTools();

though in my cases really it only saves keystrokes with admin checks and wastes them on user.

Schrank,
@Schrank@phpc.social avatar

@bobmagicii not sure what you try, but in my mind just forms $User(‚admin‘) with __invoke. And I’m not sure how serious this should be 😅🙈🤪

shudder,
@shudder@phpc.social avatar

@bobmagicii Whenever there's a context for non-object it should always be a Null object.

Primitive null is not a mistake itself, but it should be like virtual photon - use it to exchange information between adjacent particles, but don't let it travel.

bobmagicii,
@bobmagicii@phpc.social avatar

@shudder classifying it as a should, is debatable.

things like, im not going to transmit you json for a full empty user. you're gonna get a null.

then there are things like resource usage. was your infrastructure depending on 60% of your users not being logged in to have enough ram 🤣

shudder,
@shudder@phpc.social avatar

@bobmagicii Everything is debateable if you have enough time. At this point I don't know how many clarifying questions I need to get it on topic.

For example:

  • What do you mean by "you get a null"? A client object? (that's not what I described as "traveling null") API user? (that would be more like empty body for 4xx response)
  • Why do you accept empty user if you don't want to respond to it?
  • What makes the difference between asking NullUser if he's registered and checking it for null?
  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • ngwrru68w68
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • megavids
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • provamag3
  • JUstTest
  • All magazines