Instance Creation Pattern

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

Instance Creation Pattern

Sean P. DeNigris
Administrator
I've seen a lot of code like:
MyAbstractSuperclass>>subclassInstanceAppropriateFor: anObject
Which returns an instance of a subclass specialized for anObject. I don't see how I would integrate this type of code with magritte. Am I missing something obvious?

Thanks!
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Instance Creation Pattern

Damien Cassou
On Sat, Sep 21, 2013 at 4:07 AM, Sean P. DeNigris <[hidden email]> wrote:
> MyAbstractSuperclass>>subclassInstanceAppropriateFor: anObject
> Which returns an instance of a subclass specialized for anObject. I don't
> see how I would integrate this type of code with magritte. Am I missing
> something obvious?


I don't understand the question.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Success is the ability to go from one failure to another without
losing enthusiasm."
Winston Churchill
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Instance Creation Pattern

Sean P. DeNigris
Administrator
Damien Cassou wrote
I don't understand the question.
Thanks for the reply. What I was pondering was the apparent mismatch between the memento way of object creation and class-side instance creation methods which need some information passed to them to determine which subclass to actually return an instance of.


I guess what I need is something like:
MySuperclass new asMorph
        addButtons;
        addWindow;
        onAnswer: [ :e | subclassInstance := MySuperclass instanceCreationMessage: e releventInformation ];
        openInWorld.
Cheers,
Sean