Some advices to build classes, plz

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi to all,

Im trying to understand how to separate the different layers inside an application (appearance layer, data layer, bussiness layer)...

i have a database of products very simple with a table that its "Products" and another that its "ProductsType"

I created a class with the same properties as fields i have in the Products Table
at the same time in this class i have as methods as StoredProcedures about products i have in the DataBase (for example:MethodAddProduct, MethodDeleteProduct,MethodGetProductById(int ID)), etc....

and another class with the same properties as fields i've in the ProductsType Table (food, drinks, etc...)

This are my questions:

Its this a good way to work with it?...
What its the best way for bind the classes that will contain the information (for instance of a product), and the appearance(interface) layer?
 
It does mean if you need to change the structure of the database, you have to rewrite your program. It might be better to get the names of fields and tables etc from the database at runtime and have a single set function which takes the name of the field and the data to put in it as string parameters

setfield(string table_name,string field_name, string value)
 
Back
Top