Class for different purposes
I have a class that is used by two different processes with each process using different properties of the class. Every time a process requires a new property, I just add it to the class. It is a bad idea? Should I just create two separate classes and update them as needed?
NB From time to time the same property is used by both processes and each process uses a different instance of the class.
+1
source to share
3 answers
"Shared properties can be stored in one class. Then you can get two different classes from a common class and add specific properties" - Kirtan Gore
class BaseClassWithSharedProperties
{
public Int32 SharedId { get; set; }
public String SharedName { get; get; }
}
class UniqueClassNumberOne : BaseClassWithSharedProperties
{
public UniqueClassNumberOneProperty { get; set; }
}
class UniqueClassNumberTwo : BaseClassWithSharedProperties
{
public UniqueClassNumberTwoProperty { get; set; }
}
+1
source to share