Should an image be able to resize itself in OOP?

Posted by ChocoDeveloper on Programmers See other posts from Programmers or by ChocoDeveloper
Published on 2012-08-31T02:37:24Z Indexed on 2012/08/31 3:49 UTC
Read the original article Hit count: 193

Filed under:
|

I'm writing an app that will have an Image entity, and I'm already having trouble deciding whose responsibility each task should be.

First I have the Image class. It has a path, width, and other attributes.

Then I created an ImageRepository class, for retrieving images with a single and tested method, eg: findAllImagesWithoutThumbnail().

But now I also need to be able to createThumbnail(). Who should deal with that? I was thinking about having an ImageManager class, which would be an app-specific class (there would also be a third party image manipulation reusable component of choice, I'm not reinventing the wheel).

Or maybe it would be 0K to let the Image resize itself? Or let the ImageRepository and ImageManager be the same class?

What do you think?

© Programmers or respective owner

Related posts about object-oriented

Related posts about ddd