Seaside Book Chapter 15.3: Question about "A word about design"..

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

Seaside Book Chapter 15.3: Question about "A word about design"..

Helene Bilbo
Hi,
in the Seaside Book at the beginning of chapter 15.3 there is a "note about design" that says that the shown design (directly accessing the singleton of the model in the view) is just for producing a running application quickly but is not good design.
Could someone describe for a programming amateur like me what the "good design" would look like? It says to add an instance variable - but I am not so sure about how the instance variable should be initialised to the model..

thank you for an explanation,
helene.
Reply | Threaded
Open this post in threaded view
|

Re: Seaside Book Chapter 15.3: Question about "A word about design"..

Lukas Renggli
Hi Helene,

Right, an instance variable holding the model is definitely needed.
Like this you can change the model to whatever model instance you
like.

For example, if you want to let your user manage multiple todo-lists
or if you support multiple users with different todo-lists you can
instantiate the component with the right model. In both of these
use-cases you would need additional components that handle the login
or todo-list selection. And these components would then set the right
model of ToDoListView.

To make ToDoListView also work if it is used as the root component (as
in the book) you might want to use lazy initialization of the model
while also allowing the advance use-case (for later):

  ToDoListView>>model: aTodoList
      model := aTodoList

  ToDoListView>>model
      ^ model ifNil: [ model := ToDoList default ]

Hope this makes sense?

Cheers,
Lukas


On 19 December 2011 12:31, Helene Bilbo
<[hidden email]> wrote:

> Hi,
> in the Seaside Book at the beginning of chapter 15.3 there is a "note about
> design" that says that the shown design (directly accessing the singleton of
> the model in the view) is just for producing a running application quickly
> but is not good design.
> Could someone describe for a programming amateur like me what the "good
> design" would look like? It says to add an instance variable - but I am not
> so sure about how the instance variable should be initialised to the model..
>
> thank you for an explanation,
> helene.
>
> --
> View this message in context: http://forum.world.st/Seaside-Book-Chapter-15-3-Question-about-A-word-about-design-tp4213738p4213738.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



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

Re: Seaside Book Chapter 15.3: Question about "A word about design"..

Helene Bilbo
Lukas Renggli wrote
Hope this makes sense?
Yes it does. Thank you for the detailed explanation.
Best regards,
Helene.