title: In Practice, Should all the objects of a class be made to have same number of attributes?
body: <p>Which is the better coding practice?</p>
  
  <p>Sample the following (written in python):</p>
  
  <pre><code>class sampleClass:
     def __init__( self, filter ):   #filter is a string
        self.indexed = False #no
        filterTokens = filter.split()
        if ( filterTokens[0].isdigit ):
           self.indexed = True #yes
        else:
           return
        self.action = filterTokens[1]
        self.protocol = filterTokens[2]
        self.validity = True #valid
        if ( self.protocol == 'ip' )
           #something
        elif ( self.protocol == 'tcp' )
           #someOtherThing
        else:
           self.validity = False #Invalid
  </code></pre>
  
  <p>Now, if the first <em>token</em> in <em>filter</em> is not a number, the object of the class will have just one attribute - <em>indexed</em>.</p>
  
  <p>The above class could have hundreds of attributes. In such a case which is a better coding practice - </p>
  
  <p>To have same number of attributes for all the objects. (i.e define all the attributes at the top of the constructor, giving them some default value or another)</p>
  
  <p>Or</p>
  
  <p>The other way (as in the sample above)</p>
  
  <p>Eg.</p>
  
  <pre><code>filter = '10 permit ip 10.10.10.0/28 20.20.20.0/28'
  obj = sampleClass(filter)
  </code></pre>