CUTCODEDOWN
Minimalist Semantic Markup

Welcome Guest
Please Login or Register

If you have registered but not recieved your activation e-mail in a reasonable amount of time, or have issues with using the registration form, please use our Contact Form for assistance. Include both your username and the e-mail you tried to register with.

Author Topic: Any objections to anonymous functions?  (Read 817 times)

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 791
  • Karma: +143/-1
    • CutCodeDown -- Minimalist Semantic Markup
Any objections to anonymous functions?
« on: 7 Dec 2020, 02:38:23 am »
I know for a fact that a future version of this is going to use anonymous functions for loading template components. They'll be added to an array where each entry will have the anonymous function of the template component, (or a printf string!) as well as pointers to the next anonymous function in a parameter "chain".

That'll make sense later.

But does anyone here have issues with the idea of my converting process and output routines to anonymous functions instead of polluting the namespace?

PHP even having anonymous functions is pretty new. I'm not certain of if it will introduce performance concerns or not -- it shouldn't but this is PHP after all.

It would greatly simplify the back-end logic if all process() routines

Likewise, perhaps $data should be a object with getters/setters? I'm... iffy about doing that. Would be nice to "force" the idea of "module name" separations instead of blindly hoping people use good naming conventions.

Just looking for arguments both for and against here. I'm really undecided.

Though the next big thing on my to-do list is a style guide for the codebase. Something I SHOULD have done at the start, but at the start I wasn't taking this as seriously as I really wasn't expecting so many of you to take it out for a run.
I'll fix every flaw, I'll break every law, I'll tear up the rulebook if that's what it takes. You will see, I will crush this cold machine.

benanamen

  • Full Member
  • ***
  • Posts: 160
  • Karma: +14/-0
Re: Any objections to anonymous functions?
« Reply #1 on: 7 Dec 2020, 12:25:52 pm »
Likewise, perhaps $data should be a object with getters/setters?

When I see getter/setter alarm bells go off and red flags start waving. If you are using getters/setters you are breaking encapsulation.
To save time, let's just assume I am never wrong.

Jason Knight

  • Administrator
  • Hero Member
  • *****
  • Posts: 791
  • Karma: +143/-1
    • CutCodeDown -- Minimalist Semantic Markup
Re: Any objections to anonymous functions?
« Reply #2 on: 7 Dec 2020, 05:14:20 pm »
When I see getter/setter alarm bells go off and red flags start waving. If you are using getters/setters you are breaking encapsulation.
The WHAT now?!? How is a technique that leverages the protections of encapsulation breaking it?!? that's a new idea to me.

Or are you only thinking strict encapsulation, and not data verification/access restriction? As in you don't use private and getters to create scoped read-only? (aka the data access level "parked" that PHP strangely lacks?)

Set validation, construction, and locking are all different "levels" of encapsulation; there's more to it than 100% private.

-- edit -- though I may have a different viewpoint on that coming from those years programming Ada. Seriously, can you explain in more detail why you think that way?
« Last Edit: 8 Dec 2020, 06:07:12 am by Jason Knight »
I'll fix every flaw, I'll break every law, I'll tear up the rulebook if that's what it takes. You will see, I will crush this cold machine.

 

SMF spam blocked by CleanTalk

Advertisement