Consider the following two classes that implement a bunch of properties from an interface:
Interface Code:
public interface ISample
{
int x;
string y;
}
Grade 1:
public class SampleA: ISample
{
public int x { get; set; }
public string y { get; set; }
}
Grade 2:
public class SampleB: ISample
{
public int x { get; set; }
[Decorated]
public string y { get; set; }
}
The only difference is that it SampleBhas one property decorated with an attribute.
This is very simplified, and the classes in question have much more properties, but the main differences of one class have some properties decorated with attributes.
In the future, there will be situations when additional classes will be introduced that implement the interface ISampleand feel that these classes should probably inherit some common code, possibly from an abstract class or something else.
What would be a good approach to refactoring this code?
source
share