design - Is it better to assign variables in a class itself or in the class' constructor? -


It's a type of design, and I'm sure there are people who do it in both ways. But in your opinion, is it better to specify a variable in the class or the constructor? For example (regardless of syntax or language, this is just to explain):

  public class examples {private finals full TIME_STAMP = now (); Private intake number = 2; }  

OR public class example {Private Readonly Inc. TIME_STAMP; Private prime number; Public Example () {TIME_STAMP = now (); Number = 2; }}

Please ignore the mix of different languages ​​and syntax ... which is better and why?

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -