Helpers and Other Conventions - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31) +--- Thread: Helpers and Other Conventions (/showthread.php?tid=65588) |
Helpers and Other Conventions - prezire - 06-28-2016 It's better to implement InterCaps/BaseCaps for classes and camelCasing for methods. I'm not exactly sure if https://github.com/bcit-ci/CodeIgniter4/blob/develop/system/Helpers/url_helper.php is the official GitHub repository however, it would be nice to have something like: Code: use Helpers\UrlHelper; The methods are mostly static in order to imply implicit method calls. I also noticed the parent folder HTTP which, looks a bit odd. If all caps is applied, the filename would look like URLHelper.php instead of UrlHelper.php. Root folders are lower-cased as well. Is it for BC? RE: Helpers and Other Conventions - kilishan - 06-28-2016 Here's the styleguide: https://bcit-ci.github.io/CodeIgniter4/contributing/styleguide.html However, we don't have any plans at the moment to convert helpers to static classes. I've always been told that simply shoving a bunch of procedural functions into a class is "doing OOP wrong", so that's where my bias comes from. I will admit the syntax is, in some ways, nicer, and in other ways not to much. I can also see it being problematic with things like the form validation, if it stays anywhere close to how it is, and maybe some other things we have cooking. RE: Helpers and Other Conventions - prezire - 06-28-2016 Cool. Perhaps camelCased functions would be enough. It's in the Procedural Code section in the styleguide however, underscores don't seem to be consistently used anymore on modern PHP functions or methods. Keep up the good work guys! Excited for CI4... RE: Helpers and Other Conventions - Narf - 06-29-2016 (06-28-2016, 09:06 PM)kilishan Wrote: Here's the styleguide: https://bcit-ci.github.io/CodeIgniter4/contributing/styleguide.html It's not OOP at all, you're not using objects. The only reason for that usage is lack of function autoloading. RE: Helpers and Other Conventions - prezire - 06-29-2016 I believe Validation is fine instead of FormValidation. I recall CI3 had Rules http://icecream.me/3b712753751a989683ac6f3995f37f0b. Having them as constants would be nice: Validation::REQUIRED, Validation::MATCHES, Validation::IS_UNIQUE, and so forth. I noticed second thoughts about keeping the Helper Doc http://icecream.me/26b32b0970667b87a1a3242b05208320. Shouldn't it be like this http://icecream.me/358033b5c59bada3ae6696b2900bcc4e? RE: Helpers and Other Conventions - ciadmin - 06-29-2016 The helpers that will be in CI4 will be implemented as part of Phase 2, per the roadmap. The user guide will be updated then too. RE: Helpers and Other Conventions - kilishan - 06-29-2016 (06-29-2016, 01:17 AM)Narf Wrote: It's not OOP at all, you're not using objects. Sure it is. Classes are objects, and it's got methods. That makes it a (really poorly designed) object, right? But, yes, I know what you mean. The other valid reason I've heard for doing that is it limits the global function pollution. Neither one of those are good enough reasons for me to consider the change, though. RE: Helpers and Other Conventions - InsiteFX - 06-29-2016 Interesting read about this: Are PHP developers functophobic? RE: Helpers and Other Conventions - kilishan - 06-29-2016 (06-29-2016, 06:26 AM)InsiteFX Wrote: Interesting read about this: I would say that, yes, yes they are. Reminds me of a cartoon I saw once but cannot find right now that went through a progression as a developer got more experienced from a really simple solution as a new coder to more and more OOP abstractions as they got better, until the veteran was doing the same thing as a new dev. To be fair, though, it's a hard balance to keep sometimes, and there are lots of very loud voices out there telling us all how it should be done. It's hard to hear reason through the noise at times. Especially when we're all just trying to do it "the right way" RE: Helpers and Other Conventions - prezire - 06-29-2016 functophobic is funny. @kilishan I'm seeing your way about helpers. You're right. It is weird creating classes with only static methods in them. But 3 things would be nice for procedural helpers: 1. Please use camelCase function names 2. Use namespace. I hope this will remove the constant usage of function_exists() as well 3. Use InterCaps (instead of snake_case as stated in the styleguide) for filenames Code: formOpen(); |