I am building an application that transfers data from a MySQL Database to a SQLite Database. In designing the application, I have found that I require many global variables to accomplish this. Within a module, I am currently up to about forty (40) properties. This seems a bit awkward to have this many properties as global variables. Is this best practice to have this many properties as global variables?
That is a lot of globals, but it depends a little on what they represent. If they are data from a database table, then they should be in a class instance, instead of individual globals. You can easily pass an instance as a parameter to a method, which allows you to have no globals in that scenario.
Method1 reads the mysql database and creates a class instance and assigns the data to properties of the class.
It then passes that object variable to Method2.
Method2 reads the values from the object and inserts them into the sqlite database.
Something else that may help you along…put them in a Module and define them as Protected. That way you must include the Module name when you use them. So instead of:
dim s as integer = MyGlobalVar
You might have:
dim s as integer = DBStuff.MyGlobalVar