In class library I am currently working on, I need to implement a mechanism in which class users will get hold of an item by operating on an Issuer class:
class Issuer {
public Item GetItem () {
return queue.Pop ();
}
}
//at some other place
var item = issuer.GetItem ();
//work on item and submit back to Issuer
How can I implement this pattern which minimizes the risk that user of the class doesn't even bother to submit it back?
My order of preference would be:
- Class user doesn't have to explicitly submit it back
- Class user has to explicitly submit it back but it is not possible to get away without submitting (exceptions???)
- It is possible to even get away without submitting it back but the design encourage user not to do it
I know it is not a crystal clear question but any suggestions/design-pattern to implement above would be helpful!