General Class/OOP Question

jraitchi

New member
Joined
Oct 4, 2010
Messages
2
Programming Experience
3-5
I'm just getting started with OOP and VB, and I have a pretty basic question that I was hoping you could help answer. I am going to be using some physics constants quite often (for instance diameter of the Earth, Earth gravitational constant, etc) and for every program I write I don't want to have create variables for these. What would be the best way to go about doing this?

I was thinking create an Earth class in its own EarthConstants.vb file, and declaring the constants in this class. That way in each program that I am going to be using these constants I could import the EarthConstants.vb file, and use for example Earth.Diameter, Earth.GravitationalConstant, correct?

Would there be a better way to do this, maybe add the Earth class to the VB "library" (I have no idea how to do this) so I wouldn't have to import the Earth.vb every time?

Thanks very much
 
I was thinking create an Earth class in its own EarthConstants.vb file, and declaring the constants in this class. That way in each program that I am going to be using these constants I could import the EarthConstants.vb file, and use for example Earth.Diameter, Earth.GravitationalConstant, correct?
Yes, but if you decide to change something in this class you have to update each project that contains it.
Would there be a better way to do this, maybe add the Earth class to the VB "library" (I have no idea how to do this) so I wouldn't have to import the Earth.vb every time?
One of the ideas about libraries is to have a single place to maintain code, when the same code is used in two or more projects. A class library is compiled to a standalone assembly, usually to a file having the .dll extension, and you add reference to it in each project to use it.
 
Back
Top