Design Pattern For Accessing Model from View/Controller?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Design Pattern For Accessing Model from View/Controller?

Conrad Taylor
Hi, I have created a subclass of WAComponent.  Also, I have a class that represents a model and is a subclass of Object.  Thus, I was wondering, what's the best way to connect the my model to my component?  BTW, I have read the C. David Shaffer's tutorial, "Interlude:  Cleaning up the PersonalInformationView" and I'm just trying to see what the best approach for this.  Well, thanks in advance.

-Conrad





_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Design Pattern For Accessing Model from View/Controller?

Philippe Marschall
2007/8/29, Conrad Taylor <[hidden email]>:
> Hi, I have created a subclass of WAComponent.  Also, I have a class that
> represents a model and is a subclass of Object.  Thus, I was wondering,
> what's the best way to connect the my model to my component?  BTW, I have
> read the C. David Shaffer's tutorial, "Interlude:  Cleaning up the
> PersonalInformationView" and I'm just trying to see what the best approach
> for this.  Well, thanks in advance.

In general the view components directly reference the model, e.g. from
an instance variable.

Cheers
Philippe

> -Conrad
>
>
>
>
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Design Pattern For Accessing Model from View/Controller?

Conrad Taylor
Hi Philipee, thanks for responding to my post.  For example, in Shaffer's tutorial, he did something similar to the following:

 
WAComponent subclass: #PersonalInformationView

model
  ^model

model
  model := anObject

WAComponent subclass: #AddressBook

edit:  aPerson  
   |view|
   view := PersonalInformationView new.
   view model:  aPerson
   self call: view.

Thus, I take it that one needs to have accessors on the view if you're wanting to modify an instance of a model.  Now, each renderContentOn: represents a single view.

-Conrad

 
On 8/29/07, Philippe Marschall <[hidden email]> wrote:
2007/8/29, Conrad Taylor <[hidden email]>:
> Hi, I have created a subclass of WAComponent.  Also, I have a class that
> represents a model and is a subclass of Object.  Thus, I was wondering,
> what's the best way to connect the my model to my component?  BTW, I have
> read the C. David Shaffer's tutorial, "Interlude:  Cleaning up the
> PersonalInformationView" and I'm just trying to see what the best approach
> for this.  Well, thanks in advance.

In general the view components directly reference the model, e.g. from
an instance variable.

Cheers
Philippe

> -Conrad
>
>
>
>
>
> _______________________________________________
> Seaside mailing list
> [hidden email].org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
_______________________________________________
Seaside mailing list
[hidden email].org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Design Pattern For Accessing Model from View/Controller?

Philippe Marschall
2007/8/29, Conrad Taylor <[hidden email]>:

> Hi Philipee, thanks for responding to my post.  For example, in Shaffer's
> tutorial, he did something similar to the following:
>
>
> WAComponent subclass: #PersonalInformationView
>
>
> model
>   ^model
>
> model
>   model := anObject
>
> WAComponent subclass: #AddressBook
>
> edit:  aPerson
>    |view|
>    view := PersonalInformationView new.
>    view model:  aPerson
>    self call: view.
>
>
> Thus, I take it that one needs to have accessors on the view if you're
> wanting to modify an instance of a model.

Not necessarily. It doesn't really matter where the view gets the
model from but accessors are probably the most common way.

> Now, each renderContentOn:
> represents a single view.

Each instance of a  component class represents a single view.

Cheers
Philippe

> -Conrad
>
>
> On 8/29/07, Philippe Marschall <[hidden email]> wrote:
>
>
> >
> > 2007/8/29, Conrad Taylor <[hidden email]>:
> > > Hi, I have created a subclass of WAComponent.  Also, I have a class that
> > > represents a model and is a subclass of Object.  Thus, I was wondering,
> > > what's the best way to connect the my model to my component?  BTW, I
> have
> > > read the C. David Shaffer's tutorial, "Interlude:  Cleaning up the
> > > PersonalInformationView" and I'm just trying to see what the best
> approach
> > > for this.  Well, thanks in advance.
> >
> > In general the view components directly reference the model, e.g. from
> > an instance variable.
> >
> > Cheers
> > Philippe
> >
> > > -Conrad
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > Seaside mailing list
> > > [hidden email]
> > >
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> > >
> > >
> > _______________________________________________
> > Seaside mailing list
> > [hidden email]
> >
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
>
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Design Pattern For Accessing Model from View/Controller?

Conrad Taylor
Hi, is there a better way than having accessors on the view?  If so, please explain.

Thanks,

-Conrad

On 8/29/07, Philippe Marschall <[hidden email]> wrote:
2007/8/29, Conrad Taylor <[hidden email]>:
> Hi Philipee, thanks for responding to my post.  For example, in Shaffer's
> tutorial, he did something similar to the following:
>
>
> WAComponent subclass: #PersonalInformationView
>

>
> model
>   ^model
>
> model
>   model := anObject
>
> WAComponent subclass: #AddressBook
>
> edit:  aPerson
>    |view|
>    view := PersonalInformationView new.
>    view model:  aPerson
>    self call: view.
>
>
> Thus, I take it that one needs to have accessors on the view if you're
> wanting to modify an instance of a model.

Not necessarily. It doesn't really matter where the view gets the
model from but accessors are probably the most common way.

> Now, each renderContentOn:
> represents a single view.

Each instance of a  component class represents a single view.

Cheers
Philippe

> -Conrad
>
>
> On 8/29/07, Philippe Marschall <[hidden email]> wrote:
>
>
> >
> > 2007/8/29, Conrad Taylor < [hidden email]>:
> > > Hi, I have created a subclass of WAComponent.  Also, I have a class that
> > > represents a model and is a subclass of Object.  Thus, I was wondering,
> > > what's the best way to connect the my model to my component?  BTW, I
> have
> > > read the C. David Shaffer's tutorial, "Interlude:  Cleaning up the
> > > PersonalInformationView" and I'm just trying to see what the best
> approach
> > > for this.  Well, thanks in advance.
> >
> > In general the view components directly reference the model, e.g. from
> > an instance variable.
> >
> > Cheers
> > Philippe
> >
> > > -Conrad
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > Seaside mailing list

> > > [hidden email].org
> > >
> <a href="http://lists.squeakfoundation" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.squeakfoundation .org/cgi-bin/mailman/listinfo/seaside
> > >
> > >
> > _______________________________________________
> > Seaside mailing list
> > [hidden email].org
> >
> <a href="http://lists.squeakfoundation" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo /seaside
> >
>
>
> ______________________________ _________________
> Seaside mailing list
> [hidden email].org
> <a href="http://lists.squeakfoundation" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.squeakfoundation .org/cgi-bin/mailman/listinfo/seaside
>
>
_______________________________________________
Seaside mailing list
[hidden email].org
<a href="http://lists.squeakfoundation" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Design Pattern For Accessing Model from View/Controller?

Philippe Marschall
2007/8/29, Conrad Taylor <[hidden email]>:
> Hi, is there a better way than having accessors on the view?  If so, please
> explain.

That depends on your requirements. In general accessors are fine
unless you have special requirements or believe that accessors break
encapsulation.

Cheers
Philippe

> Thanks,
>
> -Conrad
>
>
> On 8/29/07, Philippe Marschall <[hidden email] > wrote:
> > 2007/8/29, Conrad Taylor < [hidden email]>:
> > > Hi Philipee, thanks for responding to my post.  For example, in
> Shaffer's
> > > tutorial, he did something similar to the following:
> > >
> > >
> > > WAComponent subclass: #PersonalInformationView
> > >
> > >
> > > model
> > >   ^model
> > >
> > > model
> > >   model := anObject
> > >
> > > WAComponent subclass: #AddressBook
> > >
> > > edit:  aPerson
> > >    |view|
> > >    view := PersonalInformationView new.
> > >    view model:  aPerson
> > >    self call: view.
> > >
> > >
> > > Thus, I take it that one needs to have accessors on the view if you're
> > > wanting to modify an instance of a model.
> >
> > Not necessarily. It doesn't really matter where the view gets the
> > model from but accessors are probably the most common way.
> >
> > > Now, each renderContentOn:
> > > represents a single view.
> >
> > Each instance of a  component class represents a single view.
> >
> > Cheers
> > Philippe
> >
> > > -Conrad
> > >
> > >
> > > On 8/29/07, Philippe Marschall <[hidden email] > wrote:
> > >
> > >
> > > >
> > > > 2007/8/29, Conrad Taylor < [hidden email]>:
> > > > > Hi, I have created a subclass of WAComponent.  Also, I have a class
> that
> > > > > represents a model and is a subclass of Object.  Thus, I was
> wondering,
> > > > > what's the best way to connect the my model to my component?  BTW, I
> > > have
> > > > > read the C. David Shaffer's tutorial, "Interlude:  Cleaning up the
> > > > > PersonalInformationView" and I'm just trying to see what the best
> > > approach
> > > > > for this.  Well, thanks in advance.
> > > >
> > > > In general the view components directly reference the model, e.g. from
> > > > an instance variable.
> > > >
> > > > Cheers
> > > > Philippe
> > > >
> > > > > -Conrad
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > Seaside mailing list
> > > > > [hidden email]
> > > > >
> > > http://lists.squeakfoundation
> .org/cgi-bin/mailman/listinfo/seaside
> > > > >
> > > > >
> > > > _______________________________________________
> > > > Seaside mailing list
> > > > [hidden email]
> > > >
> > > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo /seaside
> > > >
> > >
> > >
> > > ______________________________ _________________
> > > Seaside mailing list
> > > [hidden email]
> > > http://lists.squeakfoundation
> .org/cgi-bin/mailman/listinfo/seaside
> > >
> > >
> > _______________________________________________
> > Seaside mailing list
> > [hidden email]
> >
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
>
>
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside