OOP PHP make separate classes or one
Posted
by
user2956219
on Programmers
See other posts from Programmers
or by user2956219
Published on 2013-11-11T05:36:17Z
Indexed on
2013/11/11
10:22 UTC
Read the original article
Hit count: 250
I'm studying OOP PHP and working on a small personal project but I have hard time grasping some concepts. Let's say I have a list of items, each item belongs to subcategory, and each subcategory belongs to category.
So should I make separate classes for category (with methods to list all categories, add new category, delete category), class for subcategories and class for items? Or should I make creating, listing and deleting categories as methods for item class?
Both category and subcategory are very simple and basically consist of ID, Name and parentID (for subcategory).
© Programmers or respective owner