Inheritence
-
hi guys, I have 13 classes like clsSales, clsOrder, clsInvoice, clsEmail, clsTimesheet, etc..... every class has obviously different fields and properties. But there is one class like Sales which have all fields and properties which other classes have. Now there are 2 options first one I should create all classes seperately like clsSales saleid, orderid, orderdate, invoiceid, invoicedate, emailid, emaildate, timesheetid, timesheetdate. clsOrder orderid, orderdate clsInvoice invoiceid, invoicedate clsEmail emailid, emaildate and the second option is I should inherit all classes from clsSales class. My question is if I Implement 2nd option will this improve or make worse web page performance. thanks kind regards, learner
-
hi guys, I have 13 classes like clsSales, clsOrder, clsInvoice, clsEmail, clsTimesheet, etc..... every class has obviously different fields and properties. But there is one class like Sales which have all fields and properties which other classes have. Now there are 2 options first one I should create all classes seperately like clsSales saleid, orderid, orderdate, invoiceid, invoicedate, emailid, emaildate, timesheetid, timesheetdate. clsOrder orderid, orderdate clsInvoice invoiceid, invoicedate clsEmail emailid, emaildate and the second option is I should inherit all classes from clsSales class. My question is if I Implement 2nd option will this improve or make worse web page performance. thanks kind regards, learner
Learner520 wrote:
My question is if I Implement 2nd option will this improve or make worse web page performance.
You won't get any performance problems. Readability, maintainability and choice of design is all matters here. Also inheriting all the classes from sales just to get the common fields is not a good idea. How about a design like,
Order
orderid, orderdateInvoice
invoiceid, invoicedateEmail
emailid, emaildateSales
saleid, Order, Invoice, Email, timesheetid, timesheetdate.Sales class contains references to related classes. So to get an order id from a sales object, you could write
salesObject.Order.orderid
. You are not repeating any properties here. BTW, I don't prefixcls
to my classes. :)Best wishes, Navaneeth