this is my first question after several years of founding good answers over here. I'm re-coding one of my work trying to use a more deep level of OOP aproach but i don't know if what i'm doing is "correct".
What i'm trying to do is a simple product creation but abstract enough so the other coders doesn't have to know what db use, or how to valid product data. Just simple create($attr) method like.
This is a basic scheme of the code.
abstract class Crud_model_abstract {
# private vars
# getter for private vars
# setter for private vars
# some basic methods
}
class Product_model_crud extends Crud_model_abstract {
# private vars
# getter for private vars
# setter for private vars
# CRUD methods (using phpactiverecord.com lib)
}
Then some classes for category, brand, etc with the same structure than Product_model_crud
Now my question is this: Should I create another model that compose the actual product (add category to it's table then brand to it's table.... then create the product and store it) and then call that model from a controller passing the params, or should I convert that big model (the one that compose the product) into a controller instead.
I belive that i should create a big model, but i'm not really sure about anything at this point. I've read tooooo much material about good practices in OOP and i have doubts in every step of the way :D
What i've understand (correct me if i'm wrong) its that i should have enough layers in my code to make it more clean and specific. But in some cases i can't see when enough is enough.
Maybe it's a stupid question (of course!!) but i don't know what a hell i'm doing anymore!! Thanks you!!