Hi all,
I am trying to lay out a plan for my classes, and havent godt the most experience in oop yet.
I am using an abstract class, to be able to have a more clear overview and keep the project easier to manage.
SO:
I have created two abstract classes and extended them, so the child classes implements the desired methods.
class concrete_product_views extends abstract_product_views
{
public function display_index_products( $ProdID )
{
}
public function display_product_category( $CatID, $limit = 5 )
{
}
public function display_product( $ProdID )
{
}
}
NOW, inside this class I need to use methods from another class, which has got all the methods which defines the product carachteristics I am using for the display/output, such as: meassurements, price, thumbnails, specs, marketing text etc.
How can I use that other class inside the class above? I have allready extended it to use the abstract parent class.
Is it an "acceptable approach", to instantiate classes inside another class that is extended from an abstract class?
IS this a good/normal approach? See the first method - Do I need to instantiate that class inside EACH display method, or is there a better way? Can I implement it in the class somehow even thoug it is extended... so I dont need to do it in every display method? Its not the end of the world, Im just trying to optimize the classes, and write no more than I need :-)
class concrete_product_views extends abstract_product_views
{
public function display_index_products( $ProdID )
{
// USE DATA FROM PRODUCT_DETAIL CLASS
// WHICH IS EXTENDED FROM ABSTRACT_PRODUCT_DETAIL CLASS
$details = new product_details( $ProdID );
$measurements = $details->product_meassurements( $ProdID );
$price = $details->product_price( $ProdID );
$specs = $details->product_specs( $ProdID );
$marketing_text = $details->product_marketing_text( $ProdID );
$key_selling_points = $details->key_selling_points( $ProdID );
$thumbs = $details->thumb_images( $ProdID );
}
public function display_product_category( $CatID, $limit = 5 )
{
}
public function display_product( $ProdID )
{
}
}
Regards, Klemme