justroland
justroland
CC#
Created by justroland on 4/20/2025 in #help
✅ Abstract Class vs Interface
I am building a WPF financial application from some VBA code I'm rewriting in C#, someone else wrote the VBA and so far I've managed to translate 40% of the functionality. I have the following structure: public class I03 -> reads + filters out invalid financial transactions from a text file interface ILineItem -> defines properties for the following classes: public class HeaderData public class LineItem HeaderData and LineItem will be used in a factory design pattern, as each valid transactional data should be an instance of either of the two classes. My question is, should I have used an abstract class to derive HeaderData and LineItem from? I initially wrote the classes like this to make unit tests for each property but now I've gotten to the part where I have to think deeper about how the code will be implemented. When should we use Interfaces and when should we use an abstract class? In the latest .net sdk it seems like interfaces became more like an abstract class and I don't see the big difference, what am I missing?
15 replies