# SOLID principles can go wrong Many developers try to improve their programming practices by learning the SOLID principles. No harm here, this is a very good thing, the only problem is that without some experience (I mean a lot of it), you can easily make your code utterly complicated using the same principles that were designed to make your code nice and maintainable.

Here is a working sample application , that is used to “exemplify” the SOLID principles.

We have a basic Shape class with lots of subclasses. Each subclass has its own properties.

```
public abstract class Shape
{
public abstract double Area();

public virtual double Volume()
{
throw new NotImplementedException("You cannot determine " +
"volume from here...Method not implemented.");
}
}

public class Circle : Shape
{
public int Radius { get; set; }
public override double Area() { return 3.14 * Radius * Radius; }
}

public class Triangle : Shape
{
public int Height { get; set; }
public int Base { get; set; }
public override double Area()
{
return 0.5 * Base * Height;
}
}

public class Rectangle : Shape
{
public int Length { get; set; }
public int Breadth { get; set; }
public override double Area()
{
return Length * Breadth;
}
}

public class Square : Shape
{
public Square() { }
public int Side { get; set; }
}
```

Of course we have a factory that helps us build the shapes. Every good SOLID tutorial code must have a factory class, it is mandatory:

```public class ShapeFactory<K, T> where T : class, K, new()
{
static K k;
private ShapeFactory() { }

public static K Create()
{
k = new T();
return k;
}
}
```

And finally the actual application where we will use this monstrous code:

```class Program
{
private static void Main(string[] args)
{
try
{
var c = ShapeFactory<Shape, Circle>.Create();
if(c is Circle)
{
var circle = c as Circle;
Console.WriteLine(string.Format("{0}", circle.Area()));
}
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}", ex.Message);
}