Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

OOP design questions

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

OOP design questions

Postby sendy » Sun Dec 30, 2012 11:11 pm

hi guys, i want to ask questions for OOP designs, i want to practice to make online shop
i have some designs in my mind:
- Product class as base class for other specific product, it has(all protected) id,price, get_id(), get_price()
- Specific product class, example T-shirt, it will extends Product, it has(protected) size,colour.

the question is:
-should i use interface like Sellable (it will have methods that like get_stock(), add_stock(), etc) or should i just add the methods(get_stock(), add_stock()) in the parent class(Product class) ??

please give me some tips, i will really appreciate it.

note:sorry for the bad english.
sendy
New php-forum User
New php-forum User
 
Posts: 9
Joined: Thu Oct 25, 2012 9:47 pm

Re: OOP design questions

Postby PreetiGarg » Mon Dec 31, 2012 12:04 am

Use
methods(get_stock(), add_stock())
Its useful for you...
User avatar
PreetiGarg
New php-forum User
New php-forum User
 
Posts: 14
Joined: Fri Dec 28, 2012 2:27 am

Re: OOP design questions

Postby sendy » Mon Dec 31, 2012 12:25 am

PreetiGarg wrote:Use
methods(get_stock(), add_stock())
Its useful for you...


erm sorry sir, but should i add those methods using interface or just add it in the parent class?
sendy
New php-forum User
New php-forum User
 
Posts: 9
Joined: Thu Oct 25, 2012 9:47 pm

Re: OOP design questions

Postby simplypixie » Wed Jan 02, 2013 12:20 am

I think you are confusing things for yourself - you shouldn't have one class per product, that is not the idea of OOP. As you already have a product class, then run all your methods for anything product related within that class.
User avatar
simplypixie
php-forum Active User
php-forum Active User
 
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire

Re: OOP design questions

Postby sendy » Wed Jan 02, 2013 8:59 pm

simplypixie wrote:I think you are confusing things for yourself - you shouldn't have one class per product, that is not the idea of OOP. As you already have a product class, then run all your methods for anything product related within that class.

Okay, i think i will add those methods in the parent class(Product class) and then make a child for Product class like 'Shoes class' , 'Shirt class', etc
sendy
New php-forum User
New php-forum User
 
Posts: 9
Joined: Thu Oct 25, 2012 9:47 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron