Re: Where in the MVC should my code go?
Re: Where in the MVC should my code go?
- Subject: Re: Where in the MVC should my code go?
- From: Chase Meadors <email@hidden>
- Date: Sun, 28 Feb 2010 14:44:30 -0600
Just my 2 cents, but I see these possibilities:
1. If it's a fairly custom application, small, or simple, just combine
the code with the view since it's likely that the view will not need
to be particularly flexible or used over and over.
2. On the other hand, if you want the view to be more independent and
flexible as according to MVC, you have more options. If you're binding
the model to the view, you can simply use a custom NSValueTransformer
class to change your model attribute to an array of strings. Or you
can simply factor the code into the view controller in any way you wish.
On Feb 28, 2010, at 1:34 AM, Jean-Henri Duteau wrote:
On 2010-02-28, at 12:23 AM, Matthew Lindfield Seager wrote:
On Sunday, February 28, 2010, Jean-Henri Duteau <email@hidden
> wrote:
I don't have a good reason to not put it into the view other than
pragmatic. I can give the controller a bunch of attributes and
bind the view's controls to those attributes, as opposed to
programatically creating the strings in the view.
For small applications or simple situations it is not uncommon to
combine two roles into the one object (e.g. combining controller &
view functions or controller & model functions into one object).
I understand that. I've already split the functions - I have a
View, a ViewController, and a Model. My question is more one of
where does this code reside. I'm confident that it's not model code
- the model could care less about these strings. I'm not as
confident with my existing choice of the controller and was hoping
someone could come swooping in and say "of course that is view code
and here is why, you fool!" or "rest easy, young padawan, that is
obvious controller code".
Advice?
Read Cocoa Design Patterns by Buck & Yacktman... It's excellent
reading (& not just for its treatment of MVC).
Thanks. I have that book and have read it a couple of times. In my
opinion, it is one of the best programming books around. By
explaining the patterns that underly the various Cocoa APIs, it
really allows anyone coming from outside of Cocoa to understand it.
Having said that, I was hoping for more practical advice as I
indicated above. *smile*
BTW, I've already considered a Transformer. The problem with that
is one of code bloat - I have multiple fields on the view that are
derived from this one attribute. I haven't figured out a way at
design time in IB to make one transformer handle the different
transformations.
Jean_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden