Last post Jan 02, 2014 01:08 AM by Paul Linton
Dec 31, 2013 11:48 AM|itman1981|LINK
Currently I am learning How to write better code and I found following sample code
public interface IReport
public abstract class Report : IReport
public abstract void Print();
public class LetterReport : Report
public override void Print()
LetterReportPrinter reportPrinter = new LetterReportPrinter();
I would like to know Why there is an abstract class in between interface and LetterReport class and what is the advantage of it.
Jan 02, 2014 01:08 AM|Paul Linton|LINK
If that is all the code then there is no point to having the abstract class.
If there is other code that you have not shown (like some utility methods or other common methods) in Report then the code makes sense.
Basically, what you have shown is a pure abstract class which is effectively the same thing as an interface. There is no point in saying the same thing twice. There is no point in saying the same thing twice. (Did you see what I did there?)