Json visitor and MAFileModel

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

Json visitor and MAFileModel

Ronaldo Ferraz
Hello--

Newbie here. :-)

I'm writing a Json visitor for a project and I'd like to stream
MAFileModel on it but I'm at a loss about how to proceed.

For most simple descriptions, streaming the value is just a matter of
rendering the value according to the description using the normal
visitor pattern. However, MAFileModel is a full-blown class and
doesn't have a corresponding description to guide the process.

What would be the most interesting path here: add the required
descriptions to the classes or just go ahead and stream the
attributes?

It seems to me that the second options make the Json visitor to
tightly coupled to the MAFileModel class. On the other hand, adding
the descriptions may not be that interesting because it would mean
changing a Magritte base class.

Any suggestions?

Thanks. :-)

--
Ronaldo Ferraz
http://log.reflectivesurface.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Lukas Renggli-2
> For most simple descriptions, streaming the value is just a matter of
> rendering the value according to the description using the normal
> visitor pattern. However, MAFileModel is a full-blown class and
> doesn't have a corresponding description to guide the process.

Yes, MAFileDescription is sort of a primitive type, mainly because in  
the user interface it appears as a single upload/download field.

> What would be the most interesting path here: add the required
> descriptions to the classes or just go ahead and stream the
> attributes?

I guess it would make sense to add these descriptions as a class  
extension. This is one of most useful techniques of Magritte, that you  
can attach new descriptions to any class in the system. I use this all  
the time.

> It seems to me that the second options make the Json visitor to
> tightly coupled to the MAFileModel class. On the other hand, adding
> the descriptions may not be that interesting because it would mean
> changing a Magritte base class.

I don't know if it makes sense to add these descriptions to the core  
at the moment?

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Ronaldo Ferraz
Hi, Lukas--

>  Yes, MAFileDescription is sort of a primitive type, mainly because in
>  the user interface it appears as a single upload/download field.

That makes sense. In fact, the way I was using it until now it didn't
matter but I will have to keep a little more state for the new
functionality I'm developing, hence the question.

>  I guess it would make sense to add these descriptions as a class
>  extension. This is one of most useful techniques of Magritte, that you
>  can attach new descriptions to any class in the system. I use this all
>  the time.

I'm a bit new to Smalltalk/Squeak/Magritte terminology and I'm not
sure what class extensions mean. May I bother you for a small example
and a pointer for more explanations?

>  I don't know if it makes sense to add these descriptions to the core
>  at the moment?

That's what I thought but I was wondering about the tight coupling.
But as you mentioned, it's likely class extensions will fit what I
need--if and when I understand them. :-)

Cheers,

Ronaldo

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Lukas Renggli-2
>> I guess it would make sense to add these descriptions as a class
>> extension. This is one of most useful techniques of Magritte, that  
>> you
>> can attach new descriptions to any class in the system. I use this  
>> all
>> the time.
>
> I'm a bit new to Smalltalk/Squeak/Magritte terminology and I'm not
> sure what class extensions mean. May I bother you for a small example
> and a pointer for more explanations?

This is when you add a method to a foreign class. In your case, your  
own package adds some description methods to the foreign class  
MAFileModel. To tell Monticello that these methods belong to your code  
and not to Magritte-Core you put them into a protocol (method  
category) named *mypackagename.

Does that help?

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Ronaldo Ferraz
Ah, I see. I was already using that but my lack of familiarity with
the terms led me to think it was something else. :-)

By the way, is there a way to add instance variable using this method?
I won't need them for this particular case but I can't find any
information about that and I'll need it for another part of the
application.

Thanks again for the help. I hope you don't mind  my eventual cluelessness. :-)

Cheers,

Ronaldo

On 2/24/08, Lukas Renggli <[hidden email]> wrote:

> >> I guess it would make sense to add these descriptions as a class
> >> extension. This is one of most useful techniques of Magritte, that
> >> you
> >> can attach new descriptions to any class in the system. I use this
> >> all
> >> the time.
> >
> > I'm a bit new to Smalltalk/Squeak/Magritte terminology and I'm not
> > sure what class extensions mean. May I bother you for a small example
> > and a pointer for more explanations?
>
> This is when you add a method to a foreign class. In your case, your
> own package adds some description methods to the foreign class
> MAFileModel. To tell Monticello that these methods belong to your code
> and not to Magritte-Core you put them into a protocol (method
> category) named *mypackagename.
>
> Does that help?
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
>
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>


--
Ronaldo Ferraz
http://log.reflectivesurface.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Lukas Renggli-2
> By the way, is there a way to add instance variable using this method?
> I won't need them for this particular case but I can't find any
> information about that and I'll need it for another part of the
> application.

No that is not possible, unfortunately. Most Magritte/Pier objects  
however include a property dictionary for exactly that reason.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Ronaldo Ferraz
Okay. Thanks for the answers. I believe I now know where I'm going. :-)

Cheers,

Ronaldo

On 2/24/08, Lukas Renggli <[hidden email]> wrote:

> > By the way, is there a way to add instance variable using this method?
> > I won't need them for this particular case but I can't find any
> > information about that and I'll need it for another part of the
> > application.
>
> No that is not possible, unfortunately. Most Magritte/Pier objects
> however include a property dictionary for exactly that reason.
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
>
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>


--
Ronaldo Ferraz
http://log.reflectivesurface.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Ronaldo Ferraz
In reply to this post by Lukas Renggli-2
Okay. Thanks for the answers. I believe I now know where I'm going. :-)

Cheers,

Ronaldo

On 2/24/08, Lukas Renggli <[hidden email]> wrote:

> > By the way, is there a way to add instance variable using this method?
> > I won't need them for this particular case but I can't find any
> > information about that and I'll need it for another part of the
> > application.
>
> No that is not possible, unfortunately. Most Magritte/Pier objects
> however include a property dictionary for exactly that reason.
>
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
>
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>


--
Ronaldo Ferraz
http://log.reflectivesurface.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Ronaldo Ferraz
In reply to this post by Lukas Renggli-2
Me and my questions again.  :-)

Altough adding descriptions would not make sense to the core, would it
make sense to change MAFileModel into a MAObject? That would make it
easier to build extensions on top of it.

Cheers,

Ronaldo

On 2/23/08, Lukas Renggli <[hidden email]> wrote:

> > For most simple descriptions, streaming the value is just a matter of
> > rendering the value according to the description using the normal
> > visitor pattern. However, MAFileModel is a full-blown class and
> > doesn't have a corresponding description to guide the process.
>
> Yes, MAFileDescription is sort of a primitive type, mainly because in
> the user interface it appears as a single upload/download field.
>
> > What would be the most interesting path here: add the required
> > descriptions to the classes or just go ahead and stream the
> > attributes?
>
> I guess it would make sense to add these descriptions as a class
> extension. This is one of most useful techniques of Magritte, that you
> can attach new descriptions to any class in the system. I use this all
> the time.
>
> > It seems to me that the second options make the Json visitor to
> > tightly coupled to the MAFileModel class. On the other hand, adding
> > the descriptions may not be that interesting because it would mean
> > changing a Magritte base class.
>
> I don't know if it makes sense to add these descriptions to the core
> at the moment?
>
> Cheers,
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
>
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>


--
Ronaldo Ferraz
http://log.reflectivesurface.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Lukas Renggli-2
> Altough adding descriptions would not make sense to the core, would it
> make sense to change MAFileModel into a MAObject? That would make it
> easier to build extensions on top of it.

The idea of MAFileModel is that you can easily subclass it to provide  
your own strategy to store and retrieve the file. MAFileDescription  
takes the #kind: as an argument, so you can tell it what class to  
instantiate.

Maybe you can give an example, why you need to add new values to the  
existing MAFileModel subclasses?

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

Reply | Threaded
Open this post in threaded view
|

Re: Json visitor and MAFileModel

Ronaldo Ferraz
Sorry to reshash the subject but part of the problem has to do with
the multiple versions (thumbnaills, etc) of a file that I mentioned
briefly in the Seaside list.

i went to subclass MAFileModel but realized that because I was using a
memory representation in development to make things easier to test and
an external representation in development, I'd have to choose to
subclass only one and use it always.

Maybe I should not be bothered so much but I wondered if it wouldn't
be more interesting to keep the memory and external representations
similar.

But I was thinking about it after I sent the e-mail and maybe it would
be more interesting to write a new type of description to handle that.
I don't know, however, how that would play with the rest of the
system.  I believe Magritte makes it easy to design new descriptions,
right?

Anyway, I'm new to Magritte so maybe my models are not as well
designed as they should be. Any ideas wil be appreciated.

Cheers,

Ronaldo

On 2/24/08, Lukas Renggli <[hidden email]> wrote:

> > Altough adding descriptions would not make sense to the core, would it
> > make sense to change MAFileModel into a MAObject? That would make it
> > easier to build extensions on top of it.
>
> The idea of MAFileModel is that you can easily subclass it to provide
> your own strategy to store and retrieve the file. MAFileDescription
> takes the #kind: as an argument, so you can tell it what class to
> instantiate.
>
> Maybe you can give an example, why you need to add new values to the
> existing MAFileModel subclasses?
>
> Cheers,
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
>
>
> _______________________________________________
> SmallWiki, Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>


--
Ronaldo Ferraz
http://log.reflectivesurface.com

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki