OO Design vs Database Design
c#, n-tier-architecture, oop
Solution
Firstly, if you created a single class TransactionDA and checked types inside the class to perform CRUD operations, you would be violating the Open/Closed Principle, so I would definitely not go down that path.
As for suggestions on how to accomplish building out your DAL, I would suggest following some blog posts on people much smarter than I on what they think about this topic.
Repository is the new Singleton
Repository is Dead: Long Live Repository
Night of the Living Repositories
The conversation continues, I believe, but that should get you started.
Problem
Suppose I am developing an application for a product distributor in C#. The distributor does the following 3 types of transactions: (1) Indent (2) Sell (3) Stock I am designing my classes as follows: ``` public abstract class Transaction { } public class Indent : Transaction { } public class Sell : Transaction { } public class Stock : Transaction { } ``` Now if I want to save these three types of information in three separate tables then how should I design my DA layer? Should I build separate DA classes like ``` (1) IndentDA (2) SellDA (3) StockDA ``` or a single class `TransactionDA` and perform CRUD operations by checking their types by using `as/is` operators? Or what else can I do? Any suggestions?