I am developing an image editor app so which approach is better for class design from mentioned below? Any one of three or any new?
First
class Image{
string path
rotateLeft(){};
rotateRight(){};
changeBrightness(){};
}
or Second
class Image{
string path
}
Image image = new Image();
Class Editor{
rotateLeft(Image image){}
rotateRight(Image image){}
changeBrightness(Image image){}
}
or Third
Interface Operation{
rotateLeft(Image image);
rotateRight(Image image);
changeBrightness(Image image);
}
class Image Implements Operation{
string path;
rotateLeft(this){}
rotateRight(this){}
changeBrightness(this){}
}
please discuss pros and cons for both approach.
In my point of view I think that you can go more further in term of Single Responsibility Principle(RSP). But I'm not really sure if it relevant to make an interface for Editor.
class Image{
string path
}
Image image = new Image();
interface Rotatory {
rotate(image);
}
class RightRotator implements Rotatory{
rotate(image){
/*Your implementation*/
}
}
class LeftRotator implements Rotatory{
rotate(image){
/*Your implementation*/
}
}
interface Editor{
change(image);
}
class Brightness implements Editor{
change(image){
/*Your implementation*/
}
}