I have a requirement to save an image file in various formats. The list of formats is subject to change quite often, so I wish the saving would be very extensible. Also, the saving can take place in many places (hard disk, ftp, http, etc). The list of saving locations is going to change very often too.
I thought I would use a base Image class and many deriving classes for each format:
ImageBase {}
JpegImage : ImageBase {}
TiffImage : ImageBase{}
and handle saving in each subclass appropriately to format. Is this a good design desicion?
Also, how can I attach an extensible Saving location mechanism (Ftp, file share, etc)?
I would like something like this:
var image=ImageBase.GetImageFromDisk(path);
//some casting to subclass maybe??
var tiffImage=image as TiffImage;
tiffImage.Location=new FtpLocation();//not sure if this is a good idea
tiffImage.Save();
The problem here, is that concrete image implementation should not know or care about the saving location.
When calling Save();
on image subclass, I would like to delegate the work to some class, like FtpLocation
.
Please advice how to put the pieces together.
Thank you.
Valentin.