PPT generator using SOLID principles I want to use SOLID more and more but still learning, I'm improving a PPT generator and would like your help applying SOLID principles in it.


That generator should print two photos per slide, first one to the left, second to the right;  
If the last photo is a left photo, it should be placed in center;
Each photo has a text right below it;
I'll use a third party PPT lib to do the low level stuff.


This is what I came up with, a little bit abstracted just to pass the idea, the sample is in PHP but I'll accept answers in any programming language:

class Controller 
{
    $ppt = new Ppt(Ppt::DEFAULT_RESOLUTION, $background, $header, $footer);

    $ppt-&gt;writeSlides($photoCollection);

    $pptFile = $ppt-&gt;saveToFile();

    $ppt-&gt;deleteLocalTemporaryFiles();

    readfile($pptFile);
    unlink($pptFile);
}

class Ppt extends thirdPartyPptLib
{
    const DEFAULT_RESOLUTION = 'x';

    private $resolution;
    private $background;
    private $header;
    private $footer;

    public function __construct($resolution = null, $background = null, $header = null, $footer = null)
    {
        $this-&gt;resolution = $resolution;
        $this-&gt;background = $background;
        $this-&gt;header     = $header;
        $this-&gt;footer     = $footer;
    }

    public function writeSlides(\Traversable $photoCollection)
    {
        $i     = 0;
        $count = count($photoCollection);

        foreach ($photoCollection as $photoInfo) {
            $photoToLeft = $i % 2 == 0;
            $isLastPhoto = $i == ($count - 1);

            if ($isLastPhoto) {
                $slide = $this-&gt;newSlide();    
                $slide-&gt;addCenterPhotoInfo($photoInfo);    

            } else if ($photoToLeft) {
                $slide = $this-&gt;newSlide();    
                $slide-&gt;addLeftPhotoInfo($photoInfo);    

            } else {
                $slide-&gt;addRightPhotoInfo($photoInfo);    
            }       

            $i++;            
        }
    }

    private function newSlide()
    {
        $slide = parent-&gt;newSlide();

        if ($this-&gt;hasBackground()) {
            $slide-&gt;setBackground();
        }

        if ($this-&gt;hasHeader()) {
            $slide-&gt;setHeader();
        }

        if ($this-&gt;hasFooter()) {
            $slide-&gt;setFooter();
        }       

        return $slide;
    }
}

class Slide extends thirdPartyPptLibSlide
{
    public function addLeftPhotoInfo($photoInfo)
    {
        $this-&gt;addLeftPhoto($photoInfo-&gt;getPhoto());
        $this-&gt;addUnderlyingText($photoInfo-&gt;getText());
    }

    // functions addRightPhotoInfo and addCenterPhotoInfo very similar
}


Should I separate it more into different classes? Or methods? Should I create Interfaces?
You can remove the overloading of properties from constructor.
This way you can improve the code maintaning and readability.

An example of improvement:

class Style {
    // Properties here    
}

class Ppt {
    public function __construct(Style $style) {
    }
}


Now you pass just the object of style with all the needed properties.