I've been coding Apex alone but now other developers will be involved so I am thinking about class naming conventions. This is what I was using:

Class: ClassName

Test class: ClassNameTest

Controller: ClassNameController

Controller test class: ClassNameControllerTest

Web service class: ClassNameService

Web service test class: ClassNameServiceTest

1. Is it good/bad?

2. What is the convention for utility class that contains static methods?

3. Should I add "Trigger" at the and of trigger class name? Some people suggest doing this but triggers are in a separate package with ".trigger" at the end so I find it not needed. Am I wrong?

4. What whould be the naming convention for the instance class which object exists inside controller class?

closed as primarily opinion-based by rael_kid, Samuel De Rycke, Bob Buzzard, BarCotter, Simon Lawrence Feb 27 '14 at 12:04

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.


Check this question What is a good set of naming conventions to use when developing on the Force.com platform? and Apex-Code-Convention on GitHub

As for me, I prefer convention on GitHub.

  • Convention on GitHub looks almost what I was looking for. It is strange that Force.com does not provide the official coding conventions. – justasd Feb 27 '14 at 10:47

There is no good/bad when it comes to conventions.

I have seen a lot of code and can assure you that people/organizations have their own naming conventions.

Here is what I do normally:

  1. Triggers: tgrTRIGGERNAME
  2. Classes: clsCLASSNAME
  3. VF Pages: vfpPAGENAME
  4. Controllers: vfcPAGENAME
  5. TestClasses: testCLASSNAME
  6. Utility classes: utilCLASSNAME
  7. Classes which handle trigger code: tgrCLASSNAMEHandler
  • 2
    Sorry, I can't agree with you. For a person who always starts it's names from upper case letter it's hard to read your names. – Andrii Muzychuk Feb 27 '14 at 10:31
  • As I said, different people use different naming convention. I just mentioned what I use for my coding. User would be concerned about is class name.... the indication I have in front of everything is tell the developer what is the user of this particular file... E.g. tgrCreateTaskOnJob will actually tell you that it creates task on Job and it is a trigger. – sfguru Feb 27 '14 at 10:37
  • 1
    I understand. It's just I haven't seen anywhere such kind of naming and it seems strange to me. – Andrii Muzychuk Feb 27 '14 at 10:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.