Seaside : Confirmation email of an inscription

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

Re: Dynamic typing in smalltalk

SebastianHC
Whoop I rad wrong,.... forget the asClass thing,... this would really not work with a following perform:
What you intend to do here is really the become: thing....


Am 29.10.2010 20:23, schrieb Alexandre BP:
thanks for your time,
Your second solution seems very nice I'll try it as soon as possible.

The second one however forces me to have a big list of loops that look like '(selectedType = 'Book') ifTrue: [var := PaperBibliArticle new]. ' 
which is neither clean nor evolutive.
I wanted to do something like:

 dynamicTyping := ('PaperBibli', selectedType, ' new') asSymbol.
bibEntry := PaperBibli perform: dynamicTyping.

OR

 dynamicTyping := ('PaperBibli', selectedType) asSymbol.
bibEntry := PaperBibli perform: dynamicTyping new.

--> it doesn't work unfortunately ...

OR:

As in JAVA:

PaperBibli bibEntry;

(when I need it)
bibEntry = new PaperBibliArticle;

Anyway I'll try the second solution which is more elegant.
thank you very much
alex


 

> Date: Fri, 29 Oct 2010 13:56:14 -0300
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Seaside] Dynamic typing in smalltalk
>
> Hi Alexandre,
> I guess you could try two approaches:
>
> 1. Just list the classes in a select, so that the first step is choosing
> the entry. Once you have this you just create the appropriate class.
>
> 2. Decouple the type of the object from the object itself (check also
> http://www.ksc.com/article3.htm). Thus PaperBibli would know an object
> (lets say PaperType) whose subclasses would be Book, Article, etc. When
> the user selects the type he wants you just set the object's type. The
> type class is the one that holds the type-specific information.
>
> HTH,
> Andrés
>
> Alexandre BP escribió:
> > thank you for your replyI have a class named "PaperBibli" which keeps a list of bibliographic entries.Those entries are of different type: Article, Book, Conference,...Every type has its own fields such as: author,title,...
> > --> I created SubClasses of "PaperBibli" for each type so that when I instanciate an bibliographic entry I don't have lots of variables(fields) which are empty because not required in a particular type.The problem is that when I instanciate my bibliographic entry I still don't know of which type it is because the user tell me so by choosing in a scroll list.
> > I hope that my explanation is clear
> >
> >
> >
> > Date: Fri, 29 Oct 2010 12:24:22 -0400
> > Subject: Re: [Seaside] Dynamic typing in smalltalk
> > From: [hidden email]
> > To: [hidden email]
> >
> > There are types in smalltalk. Each object has a type.
> > That aside, what are you trying to accomplish with your example below?
> >
> > On Fri, Oct 29, 2010 at 12:13 PM, Alexandre BP [hidden email] wrote:
> >
> >
> >
> >
> >
> >
> >
> > Hello,
> > I would like to know if it is possible to apply dynamic typing in smalltalk. For example, If I want to use polymorphism, it would be:
> > var := Class new. var := (SubClass1) message. var := (SubClass2) message.
> >
> > Where message from SubClass1 is different then the one from SubClass2.Is there any solution for my problem? I know that there is no type in smalltalk but there is definitely a way to use polymorphism right?
> >
> > Thank you in advance,Regardsalex
> >
> > _______________________________________________
> >
> > 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
Reply | Threaded
Open this post in threaded view
|

RE: Dynamic typing in smalltalk

Alexandre BP
In reply to this post by SebastianHC
Great! 

I didn't see John's reply but it's definitely the best way :)

Thanks a lot everyone!
I'll surely come with new problems as I'm new with smalltalk 
Regards,
Alex


Date: Fri, 29 Oct 2010 20:43:49 +0200
From: [hidden email]
To: [hidden email]
Subject: Re: [Seaside] Dynamic typing in smalltalk

As far as I can see there's no need for your loop.
John's solution already provides you with a class in selectedType.

Eventhough it isn't quite the way to do it.
You forgot something here. Symbol new returns a Symbol:

 dynamicTyping := ('PaperBibli', selectedType) asSymbol asClass.
bibEntry := PaperBibli perform: dynamicTyping new.

asClass isn't nice because it take some while and there are more OO-solutions available.
Try to get away from casting. Delegation is the answer.

If you might need to keep your original Object, or, how to say this right now, whish or need to keep on using the memory space you could also use become: or becomeWith:
Now this is really not the nice way to do it, but it schould also work.

yourmessage: aPaperBibli
^PaperArticle new become: aPaperBibli

Just to be mentioned...

I would use John's approch, it's the most common.

Sebastian

Am 29.10.2010 20:23, schrieb Alexandre BP:
thanks for your time,
Your second solution seems very nice I'll try it as soon as possible.

The second one however forces me to have a big list of loops that look like '(selectedType = 'Book') ifTrue: [var := PaperBibliArticle new]. ' 
which is neither clean nor evolutive.
I wanted to do something like:

 dynamicTyping := ('PaperBibli', selectedType, ' new') asSymbol.
bibEntry := PaperBibli perform: dynamicTyping.

OR

 dynamicTyping := ('PaperBibli', selectedType) asSymbol.
bibEntry := PaperBibli perform: dynamicTyping new.

--> it doesn't work unfortunately ...

OR:

As in JAVA:

PaperBibli bibEntry;

(when I need it)
bibEntry = new PaperBibliArticle;

Anyway I'll try the second solution which is more elegant.
thank you very much
alex


 

> Date: Fri, 29 Oct 2010 13:56:14 -0300
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Seaside] Dynamic typing in smalltalk
>
> Hi Alexandre,
> I guess you could try two approaches:
>
> 1. Just list the classes in a select, so that the first step is choosing
> the entry. Once you have this you just create the appropriate class.
>
> 2. Decouple the type of the object from the object itself (check also
> http://www.ksc.com/article3.htm). Thus PaperBibli would know an object
> (lets say PaperType) whose subclasses would be Book, Article, etc. When
> the user selects the type he wants you just set the object's type. The
> type class is the one that holds the type-specific information.
>
> HTH,
> Andrés
>
> Alexandre BP escribió:
> > thank you for your replyI have a class named "PaperBibli" which keeps a list of bibliographic entries.Those entries are of different type: Article, Book, Conference,...Every type has its own fields such as: author,title,...
> > --> I created SubClasses of "PaperBibli" for each type so that when I instanciate an bibliographic entry I don't have lots of variables(fields) which are empty because not required in a particular type.The problem is that when I instanciate my bibliographic entry I still don't know of which type it is because the user tell me so by choosing in a scroll list.
> > I hope that my explanation is clear
> >
> >
> >
> > Date: Fri, 29 Oct 2010 12:24:22 -0400
> > Subject: Re: [Seaside] Dynamic typing in smalltalk
> > From: [hidden email]
> > To: [hidden email]
> >
> > There are types in smalltalk. Each object has a type.
> > That aside, what are you trying to accomplish with your example below?
> >
> > On Fri, Oct 29, 2010 at 12:13 PM, Alexandre BP [hidden email] wrote:
> >
> >
> >
> >
> >
> >
> >
> > Hello,
> > I would like to know if it is possible to apply dynamic typing in smalltalk. For example, If I want to use polymorphism, it would be:
> > var := Class new. var := (SubClass1) message. var := (SubClass2) message.
> >
> > Where message from SubClass1 is different then the one from SubClass2.Is there any solution for my problem? I know that there is no type in smalltalk but there is definitely a way to use polymorphism right?
> >
> > Thank you in advance,Regardsalex
> >
> > _______________________________________________
> >
> > 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

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

Re: Dynamic typing in smalltalk

Josef Springer
In reply to this post by Alexandre BP

Alexandre BP wrote:
thanks for your time,
Your second solution seems very nice I'll try it as soon as possible.

The second one however forces me to have a big list of loops that look like '(selectedType = 'Book') ifTrue: [var := PaperBibliArticle new]. ' 
which is neither clean nor evolutive.
I wanted to do something like:

 dynamicTyping := ('PaperBibli', selectedType, ' new') asSymbol.
Here you get a classname.
bibEntry := PaperBibli perform: dynamicTyping.
Try something like "dynamicTyping perform #new."
May be you must convert dynamicTyping to a real class (e.g. in VW with class QualifiedName)

OR

 dynamicTyping := ('PaperBibli', selectedType) asSymbol.
bibEntry := PaperBibli perform: dynamicTyping new.

--> it doesn't work unfortunately ...

OR:

As in JAVA:

PaperBibli bibEntry;

(when I need it)
bibEntry = new PaperBibliArticle;

Anyway I'll try the second solution which is more elegant.
thank you very much
alex


 

> Date: Fri, 29 Oct 2010 13:56:14 -0300
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Seaside] Dynamic typing in smalltalk
>
> Hi Alexandre,
> I guess you could try two approaches:
>
> 1. Just list the classes in a select, so that the first step is choosing
> the entry. Once you have this you just create the appropriate class.
>
> 2. Decouple the type of the object from the object itself (check also
> http://www.ksc.com/article3.htm). Thus PaperBibli would know an object
> (lets say PaperType) whose subclasses would be Book, Article, etc. When
> the user selects the type he wants you just set the object's type. The
> type class is the one that holds the type-specific information.
>
> HTH,
> Andrés
>
> Alexandre BP escribió:
> > thank you for your replyI have a class named "PaperBibli" which keeps a list of bibliographic entries.Those entries are of different type: Article, Book, Conference,...Every type has its own fields such as: author,title,...
> > --> I created SubClasses of "PaperBibli" for each type so that when I instanciate an bibliographic entry I don't have lots of variables(fields) which are empty because not required in a particular type.The problem is that when I instanciate my bibliographic entry I still don't know of which type it is because the user tell me so by choosing in a scroll list.
> > I hope that my explanation is clear
> >
> >
> >
> > Date: Fri, 29 Oct 2010 12:24:22 -0400
> > Subject: Re: [Seaside] Dynamic typing in smalltalk
> > From: [hidden email]
> > To: [hidden email]
> >
> > There are types in smalltalk. Each object has a type.
> > That aside, what are you trying to accomplish with your example below?
> >
> > On Fri, Oct 29, 2010 at 12:13 PM, Alexandre BP [hidden email] wrote:
> >
> >
> >
> >
> >
> >
> >
> > Hello,
> > I would like to know if it is possible to apply dynamic typing in smalltalk. For example, If I want to use polymorphism, it would be:
> > var := Class new. var := (SubClass1) message. var := (SubClass2) message.
> >
> > Where message from SubClass1 is different then the one from SubClass2.Is there any solution for my problem? I know that there is no type in smalltalk but there is definitely a way to use polymorphism right?
> >
> > Thank you in advance,Regardsalex
> >
> > _______________________________________________
> >
> > 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

--
Signature

mit freundlichen Grüßen / best regards,
Josef Springer
(Geschäftsleitung/Management)

Postal
Address
[hidden email]
Orlando-di-Lasso Str. 2
D-85640 Putzbrunn
Phone
Office
+49 (0)89 600 6920


Phone Fax
+49 (0)89 600 69220


Web
Web
http://www.joops.com


JOOPS
(HRB München 86239)

-- the software company --

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