CodeIgniter Forums
Naming & overthinking - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Naming & overthinking (/showthread.php?tid=89027)



Naming & overthinking - HarmW94 - 12-24-2023

Hi, I'm curious how you name classes, functions, variables, etc. Sometimes I notice that this can get in the way of my speed because then I start to think too hard, even though hardly anyone sees the code. But I like an overview and a standard naming for a project. This is normally how I should do it, for example:


Database (users):
  • userId
  • userEmail
  • userFirstName
  • userLastName
  • userLastSeen
  • userCreatedAt
  • userUpdatedAt
AuthController:
  • logoutHandler
  • loginHandler
  • forgotPasswordForm / (or) authForgotPasswordForm
Arrays/variables etc.:
  • $user = new User();
  • $userInfo = $user->where('userEmail', $this->request->getVar('userEmail'))->first();
  • return redirect()->route('forgotPasswordForm')
  • $routes->get('forgot-password','AuthController::forgotPasswordForm',['as'=>'forgotPasswordForm']);
So I actually use the same namings in both the Controllers/Models and in views/HTML etc..

Is that useful or could I run into problems? This is clear for me because I know exactly where to go if a problem arises somewhere. I'm curious how you guys do this!


RE: Naming & overthinking - InsiteFX - 12-24-2023

Models - UserModel

Classes - Users

Variables - userID - userName - etc;