Design patterns for Caching Images in a MVC?

Posted by Onema on Stack Overflow See other posts from Stack Overflow or by Onema
Published on 2010-12-22T21:23:12Z Indexed on 2010/12/22 23:54 UTC
Read the original article Hit count: 162

Filed under:
|
|
|

Hi,

I'm designing an image cache system that will be used in an MVC CMS. The main purpose of the image cacher is to modify images: scale, crop, etc and cache them in the client site.

I have created an image cache Model and Mapper that interact with the Database, to keep track of the images and know what kind of actions have been applied to them (scale, crop, etc).

In addition to the Model and Mapper I have created a ImageCacher Class that is used by the API to manage the Model and image creation based on arguments passed by the client site, this class creates the images and generates the links to the images for the View.

A coworker argued that I need to include the functionality of this last Class inside the Model, as the bulk of the logic should go in the model.

I respectfully disagree with him since I feel the model's responsibility is to deal with the information about the images cached at the database level, and the responsibility of the ImageCacher Class is to create the url/image that we will be caching (keeping the single responsibility principle). In addition to this I believe that a model should not have Presentation-related features, like creating or showing images.

Does anyone have any insight on this? is there a particular design pattern that would make this division of tasks clear and and the image cacher reusable? Should I add all the logic in the Model?

Thank you.

© Stack Overflow or respective owner

Related posts about image

Related posts about mvc