March 4th, 2010, 11:43 PM
Beginner Database/OOP Question
Hey, I am new to C# and object-oriented programming. Object-oriented programming involves creating classes that are used to represent objects in memory. However, in real-world applications you are probably going to want to permanently store data in a database immediately when any new data is added or changed, as to not risk losing it. I guess I'm just confused about exactly how a database should be implemented, how often it should be updated, and if you really should work directly with the database or with an object in memory. Where does the line that separates objects in memory and their existence in the database occur?
For example, I work at a bar that has several pool tables. I am trying to make an application that allows us to keep track of how long someone has been on a pool table, and thus how much money they owe (eg. 5$ an hour for pool time). From what I've learned so far, I would have a Table object for each table that would have attributes such as table number, number of players, start time, etc. All of that would be kept in memory, and any changes would be made to the object in memory. But it's important that if the computer crashes or the program crashes at any given time, that we don't lose the data for each table. So pretty much every time a change occurs, it needs to update the database. My question is do I just work directly with the database, and have no table objects in memory, or do i update the database periodically. What is the best way, in theory, to go about this? I can figure out how to use databases and everything, but i just need a general approach to use throughout my program for when and where i interact with the database.
Thanks in advance for any insight, I've made simple programs that use objects, as well as simple programs that store data in a database, but I've never made a complex real-world app that mixes both.
Tags for this Thread
Click Here to Expand Forum to Full Width