If you don't even want to have to remember to call endTest, here is what you do.
class ModuleBase {
public function startTest() {
runTest();
endTest();
}
public function runTest() {
throw new Exception("implemented in subclasses");
}
public function endTest() {
dispatchEvent({type:"end"});
}
}
Then just call startTest(). You'll never have to think of calling endTest()
again.
Scott
-----Original Message-----
From: [EMAIL PROTECTED] on behalf of erixtekila
Sent: Thu 11/24/2005 2:09 PM
To: Flashcoders mailing list
Cc:
Subject: Re: [Flashcoders] [structure] Automatic callback
Le 24 nov. 05, à 19:39, Scott Hyndman a écrit :
> You could have modules aware of their peers (like a graph or linked
> list structure) and eliminate TestSequence entirely...but it would be
> kind of odd.
>
> Otherwise you could have modules dispatch a notification when
> complete, and have TestSequence observing the modules. This would make
> the most sense...and I wouldn't consider it an explicit callback,
> since the modules will have no knowledge of the sequence's existence.
Yes, that's what I was thinking of.
But I still have to call the callback.
Here is what I was thinking of :
- TestSequence is composed with an FIFO Array, linked list, whatever…
- TestModule is a base class with only one method : endTest (b:Boolean)
- Each Test have to subclass it in order to call endTest when the
implementing test is achieved.
The endTest method is not derived by the subclass (it should declared
as final, but…)
- ITestElement is an interface that each Test have to implement in
order to force 1 method : startTest()
Sequentially, TestSequence call each entry of its stack.
Each TestElement do its stuff and, when finishing or failing, calls
endTest on the superclass.
endTest only do one stuff : calls the callback of TestSequence.
When receiving this message, TestSequence only has to go one stpe
further.
And so on…
My goal is to abstract as much as possible the test implementation.
I'd like to be able to batch as much test as I want.
But, as I am lazy (!), I'd like not to call endTest at all.
Because I am not sure that I will remember that need in months.
So, it would be pretty better for me to find an automatic way of being
called.
Follow me ?
Any idea ?
Thanks by advance.
-----------
erixtekila
http://blog.v-i-a.net/
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders