Grahaam Cox wrote on 2008-08-28 13:11:47:

> 
> Regarding the above though, if this is similar to your situation - 
> what's really wrong with model objects caching a thumbnail? Being a 
> slave to MVC is going to lead to suboptimal solutions just as ignoring 
> MVC altogether is going to be. The cached thumbnail has to be stored 
> somewhere, right? Where, doesn't really matter. So if a model object 
> has a -thumbnail method that returns the thumbnail when you need it, 
> what's wrong with that? The thumbnail doesn't need to end up 
> permanently stored by the model when archived, just created lazily 
> when required. If the model object is the best object to make and 
> cache that thumbnail (i.e. it has all the state information to hand to 
> do so) why not let it? A view that displays the thumbnail can then 
> just request it directly from the object in question instead of going 
> round the houses to generate a thumbnail simply to avoid the model 
> object getting its hands dirty. Some may feel differently but I don't 
> see that this violates MVC in any significant way and it's much simpler.

Your model objects could be re-used somewhere that AppKit isn't available 
or where it's unnecessary and perhaps even inappropriate to keep NSImages 
around; your command-line interface to the model probably won't need them, 
for instance.  As such, following the Decorator pattern by having an 
object which does "appkit-can-draw-this" and has-a model object promotes 
re-use of the model.  It also keeps all of your AppKit code in the view, 
so when you need an 
"other-ui-framework-which-I-will-not-specify-can-draw-this" object, you 
don't have to go hunting around for all that drawing code.

As others have pointed out if you don't need extra ivars, or don't mind 
jumping through a hoop to get them, you can add a category to the model 
class which is decorating via ObjC magic.  It still lets you separate the 
UI code into the view package, but also means you directly use the model 
class.  An example of that approach is 
NSAttributedString(AppKitAdditions).

Cheers,
Graham.



-- 
Graham Lee
Senior Macintosh Software Engineer, Sophos

Tel: 01235 540266 (Direct)
Web: http://www.sophos.com
Sophos - Security and Control

Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon,
OX14 3YP, United Kingdom.

Company Reg No 2096520. VAT Reg No GB 348 3873 20.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to