Jump to content

DarkAngelBGE

WFG Retired
  • Posts

    7.686
  • Joined

  • Last visited

Posts posted by DarkAngelBGE

  1. Hello Manuel, welcome aboard. :( Good to have one from Italy here ... I have been there twice already - once in Rimini (school trip! :D) and once in Venetia (awesome city).

    My name is Tim, but you can call me Timbo. Together with my Community Guardians I hold the community part of the Wildfire Games fort. :P

    In my real life I am currently a student in Berlin/Germany - it will be my last year before I will apply to an university.

    Welcome again. ;)

  2. Oh and maybe you want to generally switch to K&R-style brackets usage. That means that you do

    1: 
    2: function someFunction() {
    3: //
    4: //
    5: //
    6: }
    7: 

    instead of

    1: 
    2: function someFunction()
    3: {
    4: //
    5: //
    6: //
    7: }
    8: 

    It is the general style most Java and PHP coders use. Here's an example of what the difference could be:

    Without K&R style:

     1: <?php
     2: require_once(VIEW_HELPER_PATH.'ViewHelper.class.php');
     3: 
     4: class AlternatingRowColorer extends ViewHelper
     5: {
     6:  private $rows;
     7:  private $anchor;
     8:  private $cssClass1;
     9:  private $cssClass2;
    10: 
    11:  /**
    12:   * Our constructor
    13:   * takes the rows and the css anchor names
    14:   * @param $rows An array of strings
    15:   * @param $anchor The anchor that will be replaced
    16:   * @param $cssClass1 The first css class replacer
    17:   * @param $cssClass2 The second css class replacer
    18:   */
    19:  public function __construct($rows=array(), $anchor, $cssClass1, $cssClass2)
    20:  {
    21:   $this->rows=$rows;
    22:   $this->anchor=$anchor;
    23:   $this->cssClass1=$cssClass1;
    24:   $this->cssClass2=$cssClass2;
    25:  }
    26: 
    27:  /**
    28:  * Processing function
    29:  * Does the actual replacing of anchars with css classes
    30:  * @return an array of altered strings
    31:  */
    32:  public function fetch()
    33:  {
    34:   $i=0;
    35:   
    36:   foreach($this->rows as $row)
    37:   {
    38:    if($i % 2 == 0)
    39:    {
    40:     $row=str_replace($this->anchor, "class=\"".$this->cssClass1."\"", $row);
    41:    }
    42:    else
    43:    {
    44:     $row=str_replace($this->anchor, "class=\"".$this->cssClass2."\"", $row);
    45:    }
    46:   
    47:    $this->rows[$i]=$row;
    48:    $i++
    49:   }
    50:   
    51:   return $this->rows;
    52:  }
    53: }
    54: ?>
    55: 

    With K&R style:

     1: 
     2: <?php
     3: require_once(VIEW_HELPER_PATH.'ViewHelper.class.php');
     4: 
     5: class AlternatingRowColorer extends ViewHelper {
     6:  private $rows;
     7:  private $anchor;
     8:  private $cssClass1;
     9:  private $cssClass2;
    10: 
    11:  /**
    12:   * Our constructor
    13:   * takes the rows and the css anchor names
    14:   * @param $rows An array of strings
    15:   * @param $anchor The anchor that will be replaced
    16:   * @param $cssClass1 The first css class replacer
    17:   * @param $cssClass2 The second css class replacer
    18:   */
    19:  public function __construct($rows=array(), $anchor, $cssClass1, $cssClass2) {
    20:   $this->rows=$rows;
    21:   $this->anchor=$anchor;
    22:   $this->cssClass1=$cssClass1;
    23:   $this->cssClass2=$cssClass2;
    24:  }
    25: 
    26:  /**
    27:  * Processing function
    28:  * Does the actual replacing of anchars with css classes
    29:  * @return an array of altered strings
    30:  */
    31:  public function fetch() {
    32:   $i=0;
    33:   
    34:   foreach($this->rows as $row) {
    35:    if($i % 2 == 0) {
    36:     $row=str_replace($this->anchor, "class=\"".$this->cssClass1."\"", $row);
    37:    } else {
    38:     $row=str_replace($this->anchor, "class=\"".$this->cssClass2."\"", $row);
    39:    }
    40:   
    41:    $this->rows[$i]=$row;
    42:    $i++
    43:   }
    44:   
    45:   return $this->rows;
    46:  }
    47: }
    48: ?>
    49: 

    You see with K&R style the code looks a bit cleaner and thinner, especially when using many if-clauses. In big files this really can make a huge difference. Good for your eyes. :D

  3. You should also take attention to things like this:

    15:  $result = database ($query);

    16:  // If the query failed exit the function

    17:  if (!$result)

    18:  {

    19:    return FALSE;

    20:  }

    It could be:

    1: if (!$result = database ($query);) {
    2: return FALSE;
    3: }

    And of course what Klaas said. :D

  4. Hey guys, only recently after I updated my graphics cards drivers the video quality on all my videos is extremely low and the colors are messed up. I downloaded the driver again and reinstalled but no improvement.

    Do I have to update my mainboard as well or what could be the problem? Thanks in advance gang. :D

×
×
  • Create New...