Welcome Guest, Not a member yet? Register   Sign In
Helpers and Other Conventions
#38

(07-01-2016, 03:26 AM)sv3tli0 Wrote: 1 Proposal from me.. 

Lets define Helper Interface or abstract Helper and all Helpers to become Classes. 
I will use the url_helper to explain my simple idea.

  1. Why to set class instead of the current functions ? 
  • In most of the cases inside any helper all functions have common resources which they use.
  1. In our case we can see that most of the helper functions are using Config\App, \CodeIgniter\HTTP\URI and \CodeIgniter\Services. If its 1 class with a couple of methods the how PHP OOP idea which CI is following at first place will be kept. 

... that's not a helper.

(07-01-2016, 03:45 AM)ivantcholakov Wrote: In case of Anthony Ferrara's RFC about function autoloading gets rejected (I would sorry if it happens again), there is an approach that I saw in stackoverflow and other places, it is a PHP-based implementation. Here is a link to an article where the approach seems to be best explained, there is room for optimizations, of course:

https://bryanjhvtk.wordpress.com/2014/03...ading-php/

This seems to me a possible backup alternative.

There are easier hacks, you just have to trigger the class auto-loader.

(07-01-2016, 04:01 AM)prezire Wrote:
(07-01-2016, 03:16 AM)Narf Wrote:
(07-01-2016, 03:09 AM)prezire Wrote: The goal is how to make CI4 awesome and solve issues like reserved keywords in namespaces and not to specifically fantasize for the Array helper to fit into the framework. Since there aren't any clear and final list of helpers for CI4, I used Array as an example because it's one of CI's native common helpers. Remove it if necessary.

To make it awesome, it needs to solve problems that exist. It's not like there are a thousand keywords that you need to avoid - array is literally the only one.

That's the reason I had File as a secondary example. I must have missed it, but for the sake of this thread, please provide a link that explicitely says CI4 should not include the Array helper implementation.

"File" is not a keyword.

I've explicitly said it already, and I'll say it again: CI4 should not include an "array helper".

My posts are your links.

(07-01-2016, 04:02 AM)sv3tli0 Wrote: 1 Proposal from me.. 

Lets define Helper Interface or abstract Helper and all Helpers to become Classes. 
I will use the url_helper to explain my simple idea.

  1. Why to set class instead of the current functions ?
    In most of the cases inside any helper all functions have common resources which they use.In our case we can see that most of the helper functions are using Config\App, \CodeIgniter\HTTP\URI and \CodeIgniter\Services. If its 1 class with a couple of methods the how PHP OOP idea which CI is following at first place will be kept.
  2. What will help that ?
    With class it will be a lot easier to extend any of those helper methods. Directly CI\Helper\URI can be extended inside a App\Helper\URI accessing all the services which are prepared for the URI with really easy option to control those default methods which are used at many places at any app.
  3. Accessing in all app layers Helpers..
    Helpers must be available at any place in the Apps so I think that both ways with new instance or static instance should be possible. The plus is that by this way some unnecessary code can be skipped. I mention that specially for Views as in all other places I don't see a reason to do that.. 
    URI::base_url() is a little bit shorter then something as URI::instance()->base_url().
Any group of helpers usually has common services/resources or logic and that is the reason why they are grouped.
I believe that such groups should be merged into one Class which will share any common features fast and easy.

Such complains as too long namespaces are not realistic at least for me.. because those days Composer is used massive and there some libraries which are used have really long classname + namespace .. 
Its absurd somebody to complain that he have to define what is he using at his own app..

Regards

Libraries != helpers.
Static classes != OOP.
Static functions are NOT extendable or overridable.

Helpers are only useful for their short names. You'd use a full-featured library if you didn't mind writing more code, and there's nothing wrong with that, just don't call that "helpers".
Reply


Messages In This Thread
Helpers and Other Conventions - by prezire - 06-28-2016, 08:49 PM
RE: Helpers and Other Conventions - by kilishan - 06-28-2016, 09:06 PM
RE: Helpers and Other Conventions - by Narf - 06-29-2016, 01:17 AM
RE: Helpers and Other Conventions - by prezire - 06-28-2016, 11:35 PM
RE: Helpers and Other Conventions - by prezire - 06-29-2016, 04:21 AM
RE: Helpers and Other Conventions - by ciadmin - 06-29-2016, 04:59 AM
RE: Helpers and Other Conventions - by kilishan - 06-29-2016, 06:13 AM
RE: Helpers and Other Conventions - by Narf - 06-30-2016, 01:23 AM
RE: Helpers and Other Conventions - by InsiteFX - 06-29-2016, 06:26 AM
RE: Helpers and Other Conventions - by kilishan - 06-29-2016, 06:43 AM
RE: Helpers and Other Conventions - by prezire - 06-29-2016, 03:30 PM
RE: Helpers and Other Conventions - by kilishan - 06-29-2016, 07:38 PM
RE: Helpers and Other Conventions - by prezire - 06-29-2016, 10:53 PM
RE: Helpers and Other Conventions - by sv3tli0 - 06-29-2016, 11:12 PM
RE: Helpers and Other Conventions - by prezire - 06-30-2016, 12:11 AM
RE: Helpers and Other Conventions - by sv3tli0 - 06-30-2016, 12:32 AM
RE: Helpers and Other Conventions - by jlp - 06-30-2016, 12:53 AM
RE: Helpers and Other Conventions - by sv3tli0 - 06-30-2016, 01:45 AM
RE: Helpers and Other Conventions - by mixinix - 06-30-2016, 12:24 PM
RE: Helpers and Other Conventions - by prezire - 06-30-2016, 05:21 AM
RE: Helpers and Other Conventions - by Narf - 06-30-2016, 05:55 AM
RE: Helpers and Other Conventions - by kilishan - 06-30-2016, 06:14 AM
RE: Helpers and Other Conventions - by prezire - 06-30-2016, 06:51 AM
RE: Helpers and Other Conventions - by Narf - 06-30-2016, 08:02 AM
RE: Helpers and Other Conventions - by ciadmin - 06-30-2016, 11:28 AM
RE: Helpers and Other Conventions - by jlp - 07-04-2016, 09:38 AM
RE: Helpers and Other Conventions - by ciadmin - 06-30-2016, 12:02 PM
RE: Helpers and Other Conventions - by prezire - 06-30-2016, 03:53 PM
RE: Helpers and Other Conventions - by prezire - 06-30-2016, 05:00 PM
RE: Helpers and Other Conventions - by Narf - 07-01-2016, 02:17 AM
RE: Helpers and Other Conventions - by prezire - 07-01-2016, 03:09 AM
RE: Helpers and Other Conventions - by Narf - 07-01-2016, 03:16 AM
RE: Helpers and Other Conventions - by prezire - 07-01-2016, 04:01 AM
RE: Helpers and Other Conventions - by sv3tli0 - 07-01-2016, 04:02 AM
RE: Helpers and Other Conventions - by Narf - 07-01-2016, 04:27 AM
RE: Helpers and Other Conventions - by prezire - 07-01-2016, 05:02 AM
RE: Helpers and Other Conventions - by Narf - 07-01-2016, 05:07 AM
RE: Helpers and Other Conventions - by PaulD - 07-01-2016, 05:42 AM
RE: Helpers and Other Conventions - by awalls - 07-01-2016, 09:02 AM
RE: Helpers and Other Conventions - by prezire - 07-01-2016, 06:56 AM
RE: Helpers and Other Conventions - by PaulD - 07-01-2016, 08:01 AM
RE: Helpers and Other Conventions - by prezire - 07-01-2016, 03:16 PM
RE: Helpers and Other Conventions - by jlp - 07-04-2016, 09:46 AM
RE: Helpers and Other Conventions - by arma7x - 07-01-2016, 05:24 PM
RE: Helpers and Other Conventions - by prezire - 07-01-2016, 06:03 PM
RE: Helpers and Other Conventions - by Narf - 07-02-2016, 07:48 AM
RE: Helpers and Other Conventions - by arma7x - 07-02-2016, 05:21 AM
RE: Helpers and Other Conventions - by prezire - 07-02-2016, 11:35 PM
RE: Helpers and Other Conventions - by jlp - 07-04-2016, 09:53 AM
RE: Helpers and Other Conventions - by Muzikant - 07-05-2016, 07:59 AM
RE: Helpers and Other Conventions - by prezire - 07-05-2016, 04:17 PM
RE: Helpers and Other Conventions - by prezire - 07-10-2016, 09:00 AM
RE: Helpers and Other Conventions - by mwhitney - 07-11-2016, 02:05 PM
RE: Helpers and Other Conventions - by prezire - 07-11-2016, 05:29 PM
RE: Helpers and Other Conventions - by jlp - 07-11-2016, 03:03 PM
RE: Helpers and Other Conventions - by mwhitney - 07-12-2016, 06:08 AM
RE: Helpers and Other Conventions - by prezire - 08-01-2016, 06:52 AM
RE: Helpers and Other Conventions - by kilishan - 08-01-2016, 07:10 AM
RE: Helpers and Other Conventions - by prezire - 08-01-2016, 07:56 AM
RE: Helpers and Other Conventions - by meta - 12-09-2017, 04:56 PM
RE: Helpers and Other Conventions - by prezire - 12-10-2017, 05:40 PM
RE: Helpers and Other Conventions - by meta - 12-19-2017, 01:57 PM
RE: Helpers and Other Conventions - by prezire - 12-19-2017, 10:23 PM



Theme © iAndrew 2016 - Forum software by © MyBB