Dev:Naming Convention

From ZenMagick Wiki

Jump to: navigation, search

Why naming conventions?

We prefer convention over configuration because:

  • Once you learned the rules, you automatically know what to do without much thinking
  • It helps to increase productivity in the long run.
  • These conventions are work in progress and might get refined in the near future.

Loader naming conventions for classes, methods and functions

  • Classes start with upper case and have camel case (example: ThisIsAClassName)
  • Core (as in core/mvc/store) classes start with ZM
  • One class per file with the file name case sensitive, reflecting the class name
  • Class methods are camel case starting with a lower case letter
  • Functions start with zm_
  • Functions do not use camel case but '_', for example: zm_l10n_get

Other (application) conventions

  • The main plugin class ends with Plugin
    The full class name is derived from the plugin folder name (upper case words) with Plugin appended (and ZM prefix); example: with a plugin folder name of cron the main plugin class would be ZMCronPlugin
  • Controller classes end with Controller
    Unless explicitly configured, the controller name is derived from the requestId (main_page=) applying the same rules as for plugin classes; example: main_page=foo, controller class: ZMFooController
Personal tools