skylight Posted November 29, 2005 Posted November 29, 2005 Just a thought: I made some classes equivalent with database-tables, like students and courses. If a user changes the address of the student, it has to do an Update-query to update the database record. Something like: public class MainForm: System.Windows.Forms.Form { Student student = new Student(name, id, address); ... student.Address = something_else; // updatequery code here } Would it be any good to let the "Student" object interfere directly with the database? public class MainForm: System.Windows.Forms.Form { ... Student student = new Student(name, id, address); ... student.Address = something_else; student.UpdateRecord(); } class Student { ... public void UpdateRecord() { //updatequery code here } } This way it's much more clean in the main form code, and the database is only contacted in the "Student" class. Though, I haven't seen this way of working before in examples, so there might be a catch. Any sugguestions why or why not using this method? I would also use it to delete and insert students. Quote
Cags Posted November 29, 2005 Posted November 29, 2005 I can't see why that wouldn't work assuming the Student objects have access to the database. I.e its not a member of MainForm. Quote Anybody looking for a graduate programmer (Midlands, England)?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.