Audriusa83
Programmer
I have to develop a recording system. Say, there are multiple records instructing what to check and then checks are performed over the time.
Now in my case records can be two types - Value record (with min and max values specified and check contains the actual value) and Conform record (meaning that check meets the criteria). I was thinking to make abstract record and then inherit Value and Conform records. Then I should have abstract check and inherited Value and Conform checks.
abstract class Record
{
public string Task { get; set; }
public List<Check> Checks { get; set; }
}
class ValueRecord : Record
{
public float MinValue { get; set; }
public float MaxValue { get; set; }
public void AddCheck(ValueCheck item) {
base.Checks.Add(item);
}
}
class ConfromRecord : Record
{
public void AddCheck(ConformCheck item) {
base.Checks.Add(item);
}
}
abstract class Check
{
public DateTime CreatedOn { get; set; }
}
class ValueCheck : Check
{
public float Value { get; set; }
}
class ConformCheck : Check
{
public bool IsConform { get; set; }
}
But this means I have parallel inheritance and if I'll have to change anything, I must change in two places. Is there a better, more loosely way to do it?
Now in my case records can be two types - Value record (with min and max values specified and check contains the actual value) and Conform record (meaning that check meets the criteria). I was thinking to make abstract record and then inherit Value and Conform records. Then I should have abstract check and inherited Value and Conform checks.
abstract class Record
{
public string Task { get; set; }
public List<Check> Checks { get; set; }
}
class ValueRecord : Record
{
public float MinValue { get; set; }
public float MaxValue { get; set; }
public void AddCheck(ValueCheck item) {
base.Checks.Add(item);
}
}
class ConfromRecord : Record
{
public void AddCheck(ConformCheck item) {
base.Checks.Add(item);
}
}
abstract class Check
{
public DateTime CreatedOn { get; set; }
}
class ValueCheck : Check
{
public float Value { get; set; }
}
class ConformCheck : Check
{
public bool IsConform { get; set; }
}
But this means I have parallel inheritance and if I'll have to change anything, I must change in two places. Is there a better, more loosely way to do it?