Hi list! Situation: I have a class that analyzes stuff. There are different analyzing classes, suck 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 a different set of methodes. 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 :)