Dear Experts,
I'm looking for general advice on this.
Generally, for small-but-not-quite-trivia
l tasks, I make a new class, rather than sticking a new method into my (ever-growing) "utility" class. I often then find that everything that is needed for such a small class is contained within the constructor. But in that case, instantiating the class seems very odd--because once it's done instantiating, it's outlived it's usefulness already.
For instance, I just made a class that simply adds foreign keys to a table. In the constructor, I pass it a connection, two tables names, and two lists of keys. It generates the SQL, runs it, and then it's done. There's no separate "go run the SQL" method, for instance. There's really no need for any method other than the constructor.
Can you folks tell me, in general, what am I missing in my design here? Instantiating a class and then immediately setting it to null seems crazy. Should I be doing something with static?
Thanks again.
--BrianMc1958
Start Free Trial