mercredi 18 mars 2015

Using Static "member" variables in a base class.Looking for a better approach.Singleton? or a Factory?

This may be a repetitive question,and I tried looking for answers,but couldn't still get any help. So,here is the scenario.


We have test suite,with a couple of test classes,and some other classes which we are using for setting up test data. We have a base class which has all its "member" variables declared as static. There is an initial set up method in that class,which loads a Map that contains literally all the config files data. Then this map is used later on to "initialize" the static "class" variables.


Then this class is "extended" for other purposes. I know by this time you all will be mad,but seriously I tried talking to the guys over here,they only laughed,and I am helpless.


Next part of the story is,the "base" class,is not only providing access to some static methods,but also to these static variables(as mentioned above). Also, there is a test written so that the static variables get initialized always the first.In other way all these classes have been written in groovy.In groovy there is a method setUpspec() to run always the first similar to BeforeSuite in testNg.And setUpspec is the method which is present in the "base" class doing all the setting of the static variables. I am giving a snapshot of the class. I was thinking of the Singleton pattern,but also read about Abstract Factory,I know these design patterns except not able to make a call on which on to go for. I would really appreciate any help in this.


Thanks.


Aucun commentaire:

Enregistrer un commentaire