1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Best Practices

Practices are your friends.

  1. Jeremy

    Jeremy XenForo Moderator Staff Member

    Jeremy submitted a new resource:

    Development Best Practices - Practices are your friends.

    Read more about this resource...
     
  2. SneakyDave

    SneakyDave Well-Known Member

    I don't mean to bump this, but here are some other practices I'd like to get consistency on.

    1) I assume IF/ENDIF code practice is frowned upon, using brackets such as
    Code:
    if ($something)
    {
        $this->do($something);
    }
    else
    {
        $this->(null);
    }
    
    2) Is there a best practice for using lowercase booleans vs. uppercase booleans, I'm of the understanding that lowercase booleans can be parsed faster?

    3) Is there a best practice on versioning?

    4) I suppose PHPDoc should be stated as a best practice for comments and documentation?

    5) Any guidelines on packaging add-ons, what to include in them, etc.?
     
  3. Brogan

    Brogan XenForo Moderator Staff Member

    For 3 I use:

    Major version A
    Second point B
    Minor version C
    Status X
    Patch level Y

    Status X
    1 Alpha
    3 Beta
    5 RC
    7 Stable

    Examples
    1.0.4 Beta 4 1000434
    1.3.0 RC 2 1030052
    1.4.2 1040270
    1.5.0 Alpha 1 1050011
    2.0.0 Beta 3 2000033
     
    rugk and SneakyDave like this.
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    There is nothing wrong with using if/else's as long as they are appropriate. Doing:
    PHP:
    if (false) {
      
    // do nothing
    } else { 
      
    $this->do($something);
    }
    is bad practice.

    I'm not sure you gain anything. I stick to lower case myself.

    What Paul said, it is how XF does it.

    Yes

    You should include everything necessary that you can. If anything, follow your required directory structure *exactly* when packaging.
     
    SneakyDave likes this.

Share This Page