Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming convention

Is there a naming convention for file classes and properties regarding Many-To-One / One-To-Many relations. This might sound like a classic question on naming concention but this is not, it's a question applied to relations, let's say in Doctrine for example.

This might be silly but names are quite important, aren't they?

In this case, I have an entity GolferProfile, an entity Category, and therefore want an intermediate GolferProfile-Category entity.

What class name should I use for the intermediate entity?

GolferProfileCategory OR GolferProfile_Category OR GolferProfile-Category  OR anything else?

Same with the property...I have seen people using the first letter of each class, which would be $gc in this case. This is pretty much difficult to read, but on the other hand we don't want to work with a long name like $golferprofile_category?

Any thoughts on this would help me to understand how to work with names..Cheers

like image 575
Tom Avatar asked Feb 22 '26 12:02

Tom


1 Answers

There is no rule of thumb, but I would recommend sticking to a single practice when it comes to naming conventions for everything: you seem to be using camelCase already, so why not use it for everything else?

GolferProfile
Category
GolferProfileCategory

$golferProfile
$category
$golferProfileCategory
like image 82
Mahn Avatar answered Feb 25 '26 01:02

Mahn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!