mercredi 31 mai 2017

Inheritance design concept

I have 2 unrelated classes

public class ManagedType{
    private string id;
    private string name;
    private string description;
    private string version;
    private string Properties;
   private List<string> baseTypesl
}

public class OtherClass{
    private string id;
    private string name;
    private string description;
    private string target;
    private string sources;
   private List<string> relationships;
}

So is it advised if I abstract out id, name, description into a new base class and let it extends this.

My view is that since they are unrelated we shouldn't. Also we should never extends a class only for properties(unless they are related), but only for common behaviors(which is none here). Please let me know your view on the same.

Aucun commentaire:

Enregistrer un commentaire