I know there are A LOT of the same questions, but I can't find the compination of words to find the right example, so..please help me. I have a terrible class UlesanneDb with getters, setters, constructor and override ToString() to 53 fields in database.
public string Variant { get; set; }
public string r1 { get; set; }
public string r2 { get; set; }
public string r3 { get; set; }
public string rone { get; set; }
public string rtwo { get; set; }
public string rthree { get; set; }
public string functionname { get; set; }
public string andmetype { get; set; }
public string ulesannetype { get; set; }
public string t { get; set; }
public string joonkiirus1 { get; set; }
public string joonkiirus2 { get; set; }
public string joonkiirus3 { get; set; }
public string joonkiirusA { get; set; }
public string joonkiirusB { get; set; }
public string joonkiirusC { get; set; }
public string joonkiiruslatt { get; set; }
public string joonkiiruskoormus { get; set; }
public string nurkkiirus1 { get; set; }
public string nurkkiirus2 { get; set; }
public string nurkkiirus3 { get; set; }
public string nurkkiirusA { get; set; }
public string nurkkiirusB { get; set; }
public string nurkkiirusC { get; set; }
and so on.... This is physics excersise - there is three wheels(1,2,3) and three points(a,b,c). For every wheel and point there are joonkiirus 1, nurkkiirus1 and so on.
So, I need to simplify this terrible thing. I think I need to create Classes like:
class Wheels
{
public double joonkiirus1 {get;set;}
public double joonkiirus2 {get;set;}
public double joonkiirus3 {get;set;}
public double nurkkiirus1 {get;set;}
public double nurkiirendus1 {get;set;}
// .....and so on for all the fields?
}
class Point
{
// or it should be like this
int[] pointA = new int[6] {joonkiirus1, nurkkiirus1, nurkkiirendus1, tangkiirendus1, normaalkiirendus1, kogukiirendus}; //there are 6 physical things
int[] pointB = new int[6]{same};
int[] pointC = new int[6]{same};
}
and then in UlesanneDb I need to use it like an OBJECT ARRAY. The thing is, I don't understand what I need to write in this class, so I can call it then in UlesanneDB as an object array and use it to initialize it with database fields...
//so in
class UlesanneDb{
int Variant {get;set;}
// ?? something here is definitely wrong, but i can't figure out how and what place into array, what should be just variable
Wheels wheel = new wheel {}
}
You will actually save my sanity if you explain me this T_T Please/
This is really more a comment than an answer, but it is too long for the comment field, and I suspect you will not get a satisfactory answer until you address a few problems in your question.
First, you need to explain the problem in enough detail with enough clarity that someone who doesn't have your software can understand what you have and what you're trying to do. You haven't done that. Learning how to express yourself is a critical skill and you will not become a successful software developer without learning how to do this.
Second, “53 fields in database” is a big danger sign that your data has not been normalized. You need to do this or you risk corrupting your data.
Another big danger sign is class properties named
something1
,something2
and so on. This is a symptom of designing classes from the UI or output you will generate, and not on the data you are trying to model.Yet another danger sign is many
string
data fields. Strings can store any kind of text data, including names, numbers, URLs, scripts, markup, or entire books. Can you really accept any one of those for everystring
field in your class? If not, you should use a more specialized data format.Unfortunately I cannot suggest a design because I don't understand what you are trying to model; you have to explain that first.