Oh, yes, I misunderstood you. When I read "ugly runtime errors", I
understood "a runtime action script error", like the ones are reported by
flash player debug version.

[]'s
andrei



On Sun, Mar 23, 2008 at 7:30 AM, Jeroen Beckers <[EMAIL PROTECTED]>
wrote:

> Hi Thomaz,
>
> Wouldn't that be the exact same thing as testing against the interface
> references that's stored which each analyzer (as I suggested in my post) ?
>
> Since there is no compile-time way to check this, i'm going to check all
> the
> items with all the analyzers in the analyze() method and give a runtime
> error if something's wrong.
>
> Thanks for thinking with me though! :)
>
> On Sun, Mar 23, 2008 at 2:29 AM, Andrei Thomaz <[EMAIL PROTECTED]>
> wrote:
>
> > and if each IAnalyzer implements a function called
> getAnalyzedProperty(),
> > returning a string, and if each item (using an IItem interface, for
> > example)
> > implements a function called hasProperty(), receiving a string as
> > parameter?
> > So, you could check if the item has the "getProperty()" function the
> > analyzer requires, at runtime, without having runtine errors... You
> could
> > also have some getProperty( strProperty:String ):Object function,
> defined
> > at
> > IItem interface.
> >
> > interface IAnalyzer
> > {
> >  getAnalyzedProperty():String;
> > }
> >
> > interface IItem
> > {
> >  hasProperty( strProperty:String ):Boolean;
> >  getProperty( strProperty:String ):Object;
> > }
> >
> >
> > just a guess,
> > andrei
> >
> >
> >
> > On Sat, Mar 22, 2008 at 11:39 AM, Jeroen Beckers <[EMAIL PROTECTED]
> >
> > wrote:
> >
> > > Hi list!
> > >
> > > Situation: I have a class that analyzes stuff. There are different
> > > analyzing
> > > classes, such as "HeightAnalyzer", "WeightAnalyzer", "LevelAnalyzer",
> > etc.
> > > You can add an analyzer to the class by using
> > > 'myClass.addAnalyzer(newAnalyzer:IAnalyzer)'.
> > > As you can see, there is an IAnalyzer interface which all Analyzer's
> > > implement. Every time you add an analyzer, it is added to the list
> using
> > > the
> > > Decorator pattern. (Every analyzer must analyze a list and pass it to
> > the
> > > next analyzing test)
> > >
> > > Now, the analyzer's analyze certain items. Every analyzer requires the
> > > analyzed item to have a certain set of methods. The HeightAnalyzer
> > > requires
> > > a getHeight(), the LevelAnaylzer requires a getLevel(), etc. I want to
> > > have
> > > a different interface for each analyzer, so that I can easily add
> > > analyzers
> > > (+interfaces).
> > >
> > > If I want to analyze a list of items, those items must implement the
> > > correct
> > > interface, according to which analyzers you have added to the class.
> Fe:
> > >
> > > var myClass:AnalyzerBundle = new AnalyzerBundle();
> > > myClass.addAnalyzer(new HeightAnalyzer());
> > > myClass.addAnalyzer(new LevelAnalyzer());
> > > myClass.analyze(new Array(item1, item2, item3));
> > >
> > > What I am looking for now, is a way to make sure that item1, item2 and
> > > item3
> > > all implement the IHeightItem and ILevelItem interfaces.
> > >
> > > I've found a couple of ways to do this, but none of them seemed really
> > > good
> > > to me. One of them was to have every Analyzer keep track of the
> > interface
> > > associated with it, and check if they implement the correct interface,
> > > once
> > > the analyzer is called. But this would give ugly runtime errors...
> > > I'm pretty sure that it can't be done at compile time, but if anyone
> > > happens
> > > to know some way (hack), or a better way for the runtime errors,
> please
> > > tell
> > > me :-). All ideas are welcome
> > >
> > > Ps: I've just made up all these names, my question is about the
> > technique
> > > to
> > > be used, not about the project :)
> > > _______________________________________________
> > > Flashcoders mailing list
> > > Flashcoders@chattyfig.figleaf.com
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > _______________________________________________
> > Flashcoders mailing list
> > Flashcoders@chattyfig.figleaf.com
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to