I have the following classes:
Defect - represents the type of data that can be found in the databaseFilterQuery - provides a way to query the database by installing simple boolean filters
Both Defectand FilterQueryimplement the same interface IDefectProperties. This interface indicates the specific fields that are in the database. Different classes have methods that return lists of instances Defect. With the help of FilterQueryyou specify some filters for specific properties implemented as part IDefectProperties, and then run a query and return a list of instances Defect.
My problem is that I end up implementing some properties in exactly the same way in FilterQueryand Defect. These two are essentially different classes, they just share the same properties. For instance:
public DateTime SubmitDateAsDate
{
get { return DateTime.Parse(SubmitDate); }
set { SubmitDate = value.ToString(); }
}
This is the property required IDefectProperties, which depends on another property SubmitDatethat returns stringinstead DateTime. Now SubmitDateimplemented differently in Defectand FilterQuery, but SubmitDateAsDateexactly the same. Is there any way that I can identify SubmitDateAsDateonly one location, but both Defectand FilterQuerygive it as a property? FilterQueryand Defectthey are already inheriting from two different classes, and, it seems to me, it would not make sense for them to share with their ancestor. I am also open to suggestions regarding my design here.