Skip to content

LiteCommerce development: Best Practices

beatnbite edited this page Oct 17, 2011 · 1 revision

PHP

  • Access class properties via getter and setter methods, not by direct references to the fields.

    I.e. instead of

      $this->field = 'value';
      return $this->field;
    

    use

      $this->setField('value');
      return $this->getField();
    
  • Compare with "===", not "=="

File structure

  • Group files into subdirectories. For example, create the Dialog subdirectory and put your Dialog\ADialog and Dialog\FileSelector classes there rather than placing SimpleDialog and FileSelectorDialog classes into the root directory with view classes.

File operations

  • Don't use move_uploaded_file() and file_put_contents(). Instead, do all file operations via \Includes\Utils\FIleManager class.

Networking

  • Use \XLite\Core\HTTP\Request class, not \PEAR2\HTTP\Request

HTML & CSS

  • Follow the MVC design pattern and put all view-related components and files to the "View" part (view classes and templates). Model classes should not affect the CSS and HTML of your pages directly.
Clone this wiki locally