Getting validation from inherited classes I'm building some code with an inheritance heirarchy, and I want to validate the resulting instances. At present I have a method in the base class can override to return a list of the problems (see the code).

My problem here is that this works, provided the inheriting classes remember to get the base results first, before returning their own. It works, but I'm not sure it's the best design?

using System;
using System.Linq;
using System.Collections.Generic;

namespace Query
{
    /// &lt;summary&gt;
    /// Root class with mehtod
    /// &lt;/summary&gt;
    public abstract class baseClass
    {

        /// &lt;summary&gt;
        /// Is the object valid?
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public bool IsValid()
        {
            return (!GetValidationIssues().Any());
        }

        /// &lt;summary&gt;
        /// Return list of validation issues
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public virtual List&lt;string&gt; GetValidationIssues()
        {
            var result = new List&lt;string&gt;();
            if (Quantity &lt; 0) result.Add("Quantity is invalid");
            return result;
        }

        public int Quantity { get; set; }
    }

    /// &lt;summary&gt;
    /// First child class, adds a new property and more validation
    /// &lt;/summary&gt;
    public abstract class productBase : baseClass
    {
        public override List&lt;string&gt; GetValidationIssues()
        {
            // we must get any base results first!!
            var result = base.GetValidationIssues();
            // do checks for this class
            if (string.IsNullOrWhiteSpace(Name)) result.Add("Name not specified");
            return result;
        }

        public string Name { get; set; }
    }

    /// &lt;summary&gt;
    /// Final instance
    /// &lt;/summary&gt;
    public class Product : productBase
    {
        public override List&lt;string&gt; GetValidationIssues()
        {
            // remember to get the base results first
            var result = base.GetValidationIssues();
            // do checks for this class
            if (Price &lt;= 0) result.Add("Price is not valid");
            return result;
        }

        public decimal Price { get; set; }
    }

}
Here's a C# version using a cross of the template method pattern and the collector pattern.
It'll pick up any issues from any derivative implementing the AddValidationIssues method.

public abstract class BaseClass
{
    public List&lt;string&gt; GetValidationIssues()
    {
        var result = new List&lt;String&gt;();
        if (Quantity &lt; 0) result.Add("Quantity is invalid");  
        AddValidationIssues(result);
        return result;
    }

    protected virtual void AddValidationIssues(List&lt;string&gt; result)
    {
    }
}

public class ProductBase : BaseClass
{
    protected override void AddValidationIssues(List&lt;string&gt; result)
    {
        if (string.IsNullOrWhiteSpace(Name)) result.Add("Name not specified");   
    }
}


As a sidenote, I'd look for another name than "BaseClass". It doesn't say anything about what it does.