I’m new to OOP and software design in general and I’ve been tasked to create a program to populate a database from a set of data sources. My question is at a high level, what would be a good/flexible/logical way to design the classes? The target database that I’m to build has approximately 40 already definied tables. Furthermore, these tables are grouped into 10 sets (lets call them TableSets) of related information. My initial idea was to have 3 classes: DataBase, TableSet, and Table.
-
The DataBase class would hold an array of the TableSets (1 through N)
-
The TableSet class would have an array of the Tables in that TableSet
-
The Table class would just hold data
For the methods I was thinking of having something like
DataBase.PopulateTableSet(tableSetNum)
TableSet.PopulateTable(tableNum)
Table.RunQuery or some other method to get the right data
If anyone has any suggestions on what a good way to do this is, I’d really appreciate any kind of help. Thanks for taking a look.
What you probably want to read about is a three layered application development paradigm. Essentially you’ll need to design a class that can read and write to a datasource, e.g. an SQL data source, access… etc…
Next up you’ll want a logic layer (sometimes referred to as business logic). In your logic classes you’ll do things like build up sql statements, run calculations etc… and finally a GUI layer (win forms or whatever it is you’d like to use).
You may want multiple classes in each layer, e.g. SQL class, MSAccess class or whatever data sources you’ll be reading and writing.
You may wish to look up DataTables, check out http://www.dotnetperls.com/