I'm having trouble understanding what the over-arching principle is for including static members in a class which normally acts as a blueprint for instantiation. I'll use an example:
Say you have Car class.
Class Car
{
public int yearBuilt;
public string make;
//etc
}
which is principally used to produce new cars. So you have a bunch of non-static members for this, as expected and shown above. Now, say you instantiate 2 new cars as follows
Car.newCar1 = new Car();
Car.newCar2 = new Car();
Now, lets say you have a situation where you want to assign/track the supplier for the newCar's being made today. Assuming you can only have a single supplier at any one time, you figure all newCar's made at this time should share the value, so you add to the Car class:
public static string supplier = "American AutoCompany X";
I can't now access it via the instance, IE: newCar1.supplier, else it would change the value for newCar2 (which in this context is OK and preferable), and instead would have to do this to accomplish the same goal:
Car.supplier;
I don't understand the point of this. Why not just keep your static methods/fields, etc in a completely different class like:
class AllStaticStuff
{
}
and access it from there? Organizationally that may even be preferable, since static members have nothing to do with instantiation anyhow. Or am I missing something fundamental that makes this method of organization more trouble than its worth? I guess the reason I don't like the idea of including statics in a non-static class is that I try to avoid unnecessarily growing membership in any one class as, for readabilities sake, I find it cleaner.