Wednesday 9 May 2007

Singleton Pattern - A practical use

The other day I was watching I program I think it was BBC 1 about how people's credit and detail card details are being stolen and wrongfully used when pin numbers land in hands of the wrong people.

I thought of how patterns can help in tackling this problem, I reached our Bible – GOF book, scanned through all the patterns. Guess what!

The singleton pattern I think can help tackle the problem . I this blog I share my idea about how singleton pattern is be used here.

The Singleton pattern ensures that there is one and only one instance of class and provides a global point of access to that instance.[Copper, p39]. Singleton

Every account when have one pin at a time. Using singleton pattern, systems can be designed where the uniqueness that password is limited at a given time say each week.

Suppose the banking system has an Account Class which generates pin numbers, the Account Class should only create one pin number and also destroy on a weekly basis. All subsequent pin numbers created should never be similar to the one created before on that account.

This will provide uniqueness to the weekly pin number being generated.