I have been learning more about programming lately and now some things are confusing me.
I have always been taught that its good to have an OOP design. So on a sample project I have an Employee and Customer class that inherit from a Person class. The Employee and Customer classes really don’t have any function other then to define the Employee or Customer objects.
So normally, I created these classes and then created a data provider class that sent information stored in these classes to the database (and vice versa).
In my database I also have tables called employees and customers.
I have been playing with the new Linq stuff and it seems I can connect to the database and drag the tables onto a designer. On this sample program I have PubsDataSet.xsd. Then I use data controls like BindingSource and TableAdapter, etc…, etc… and I bind the text boxes, data grids, etc… to the database that way. I can use the built-in BindingNavigator toolbar to move, add, edit, delete records.
I like this easy design.
The problem is, when I do it this way I no longer have (or need) classes like Employee or Customer or many other classes for that matter in my program. There is no need for them because the new data tools handle all of this automatically.
So now I’m confused, and I’m not sure my design is correct because as far as OOP goes I should have those classes in the program to define everything.
Take another class for example, say on a point of sale program there is a class called Transactions. That class stores all the information about a Transaction (a sale).
Before I would have all the things like (dateProcessed, terminalNumber, itemsCollection<>, discountCollection<>, etc…) in my class and also have the required functions for calculating the sale total, figuring sales tax, adding or voiding an item.
Since I am using this new database tools the definition of my Transaction class is no longer needed because its bound to the controls on the form. So my Transaction class now only has the functions mentioned above, all of the things that actually define the Transaction have been removed and moved to the new database tools.
So now, I’m confused that this is proper design, because I was always taught that my front end user interface should not contain the code for these classes, they should all have their own class. But now these classes are bound to the interface.
I guess I’m completely confused now, should I be creating classes for things like Employee and Customer or just binding them using the new tools, and if I bind them to the new tools is there really a need to still create the classes or just leave them out? Why do I need an Employee or Customer class when the form controls are bound directly to the employee and customer tables in the database? Those classes have no other function except to define an object and store the values of that object in memory.
I’m not sure what is proper design anymore.