Skip to main content
Topic: Classes naming (Read 3004 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Classes naming

I was looking around at the classes in /subs/, and... well, at the moment there are some naming variants:
I see these patterns mainly:
  • Something_Else in a file SomethingElse.class.php
  • Something_Else in a file Else.class.php
  • Something_Else in a file Something.class.php
  • Something in a file Something.class.php
Then some completely unrelated class names with file names.
And finally some special cases (search, control verification <= I should fix that, payment gateways).

What would you like best?
I think now it's one of the last moments to pick one and be happy for the 1.x line.

I think the first is the most "autoloading-friendly".
Bugs creator.
Features destroyer.
Template killer.

Re: Classes naming

Reply #1

Where is the poll  :'(   :P

I think 1 is the way to go and then I need is a way to remember that !


Re: Classes naming

Reply #2

I'd vote for one, too  :)
Thorsten "TE" Eurich
------------------------

Re: Classes naming

Reply #3

And here it is:
https://github.com/elkarte/Elkarte/pull/1593
:D

Try to review/test it before merging because I didn't. O:-)
I'll try to test something later.
Bugs creator.
Features destroyer.
Template killer.

Re: Classes naming

Reply #4

I'd use PSR compliant names: SomethingElse in SomethingElse.php

Re: Classes naming

Reply #5

Yeah, that could have been a solution, though it would have meant a rewrite of a lot of stuff in the first place...
Yesterday evening just after this was merged I was playing with an autoloader and it worked "quite well" (few problems with specific classes like search, payments, database), but overall it worked fine! :D
 emanuele wanted a naming convention because of the autoloader. :P
In the end the "_" is good because it helps identify the different kind of classes we have that need "special" rules for the autoload.

The next step for 1.1 will be to harmonize the /sources/admin directory naming, so that we could guess the place of a class just by its name and not having to use file_exists.
Bugs creator.
Features destroyer.
Template killer.


Re: Classes naming

Reply #7

Reminder bump: write these on the wiki somewhere.
Bugs creator.
Features destroyer.
Template killer.