Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

I highly encourage you to write down here all our coding conventions. From now on nobody will be able to say "how could I know?".

Most of them are highly debatable so feel free to discuss them or even prove them wrong.

Also, the thing is that you have to know the rules to be able to break them. Proper order of coding something should look like this:

  1. You consider doing it according to this conventions, assuming you fully understand them.
  2. If your common sense tells you it's not right, it probably isn't - do it your way.
  3. But don't leave it like that, talk about it, or even better update this page.

Naming conventions

Naming literals:

If the same string literal occurs more than once we extract it to a field like this:

private static final String L_STRING_LITERAL = "stringLiteral"

I know it was STRING_LITERAL_L before, but that convention didn't work for magic numbers, also if you think about it that L_ upfront tells you clearly what you deal with. That it's not a plugin specific constant nor enum.

Same thing holds for magic numbers:

private static final int L_15 = 15;

 

Naming classes/packages:

If plugin name is "mes-plugins-awesome-plugin" the basic package is: com.qcadoo.mes.awesomePlugin, we can create some additional packages (and it's very rarely we should create anything else):

  • constants - we hold here classes like AwesomePluginConstants.java and maybe some model enums that are plugin specific.
  • hooks - model and view hooks like: ViewNameViewHooks.java, ModelNameHooks.java
  • validators - model validators like: ModelNameValidators.java, SomeOtherModelNameValidators.java
  • listeners - view listeners like: ViewNameListeners.java
  • states - if there is some logic regarding model states (I consider enum state model field as something that common to write it here), for ex. ModelNameStatesService.java
  • workPlansColumnExtensionhttp://wiki.qcadoo.org/display/QCDMESDOC/WorkPlans+column+extension

We add PluginName suffix only to classes that are meant to be used outside this plugin - things like: AwesomePluginConstants.java, AwesomePluginService.java.

  • No labels