title: Is it a better practice to inject all variables in the constructor or to use setters and throw exceptions if they are not set?
body: <p>Imagine you have this class</p>
  
  <pre><code>class Ai1ec_Less_Parser_Controller {
      /**
       * @var Ai1ec_Read_Variables_Startegy
       */
      private $read_variable_strategy;
      /**
       * @var Ai1ec_Save_Variables_Strategy
       */
      private $write_variable_strategy;
      /**
       * @var Ai1ec_Less_Variables_Collection
       */
      private $less_variables_collection;
      /**
       * @var Ai1ec_Less_Parser
       */
      private $ai1ec_less_parser;
      /**
       * We set the private variables in the constructor. I feel that there are too many parameters. 
       * Should i use setter instead and throw an exception if something is not set?
       * 
       * @param Ai1ec_Read_Variables_Startegy $read_variable_strategy
       * @param Ai1ec_Save_Variables_Strategy $write_variable_strategy
       * @param Ai1ec_Less_Variables_Collection $less_variables_collection
       * @param Ai1ec_Less_Parser $ai1ec_less_parser
       */
      public function __construct( Ai1ec_Read_Variables_Startegy $read_variable_strategy,
                                   Ai1ec_Save_Variables_Strategy $write_variable_strategy,
                                   Ai1ec_Less_Variables_Collection $less_variables_collection,
                                   Ai1ec_Less_Parser $ai1ec_less_parser ) {
  
      }
  }
  </code></pre>
  
  <p>I need those variables to be set and so i set them in the constructor ( but that look like too many parameters ). Another option would be to use setters to set them and then in a method throw an exception if one of the required variables is not set like this</p>
  
  <pre><code>public function do_something_with_parser_and_read_strategy() {
    if( $this-&gt;are_paser_and_read_strategy_set === false ) {
       throw new Exception( "You must set them!" );
    }
  }  
  private function are_paser_and_read_strategy_set () {
    return isset( $this-&gt;read_variable_strategy ) &amp;&amp; isset( $this-&gt;ai1ec_less_parser );
  } 
  </code></pre>
  
  <p>Do you think that one of the two methods is better?And why?</p>