In order to create clean, decoupled code in C #, I was hoping to get some feedback on using a dynamic parameter to build objects. As a rule, I believe that you will create an interface and will use the interface as a contract, but then you need to create interfaces for all your classes, which, I think, are ridiculous ...
So my question is what are the pros and cons of doing something like this:
class Class1
{
public string Description { get; set; }
public string Name { get; set; }
public Class1(dynamic obj)
{
Name = obj.Name;
Description = obj.Description;
}
}
against
class Class1
{
public string Description { get; set; }
public string Name { get; set; }
public Class1(IClass1 obj)
{
Name = obj.Name;
Description = obj.Description;
}
}
source
share