PHP OOP structure problem, simulate multiple inheritance -


i have e-shop multiple product types. , have thought of following structure

cart_item -- cart_product -- cart_download  order_item extends cart_item -- order_product -- order_download 

the problem want have order_product extend order_item , cart_product. because needs method generic order_item ( price order not product ) methods cart_product ( shipping calculations )

i know php doesn't support multiple inheritance, wandering cleanest way emulate this.

right have order_product extend cart_product duplicate code order_item in order_product order_download.

either use interfaces , implement methods manually or via strategies. or use composition instead of inheritance, meaning let order_product have order_item , cart_product.

on sidenote: consider making "shipping calculations" it's own service class can pass appropriate product instances to.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -