4 ms·
As I mentioned in my reply to 'geocar, we would need to model the entire state machine, which (usually) means a stack or queue. while(queue.Any())
by noblethrasher 11y ago
As I mentioned in my reply to 'geocar, we would need to model the entire state machine, which (usually) means a stack or queue.
while(queue.Any())
next_queue.Enqueue(queue.Dequeue().Delete());
So, in this scheme you do lose access to the User instance once you call Delete().
A robust solution would probably involve using the visitor pattern to dispatch the correct Enqueue method of next_queue (i.e. we may have multiple next_queues), but as a side benefit of all that boilerplate, refactoring becomes simple, and you can get concurrency for nearly free.