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.

3 comments:

GillesdeBiaks said...

Happy to see what you have mentionned about Singleton Pattern. As you said in practice it is a good idea to use it as it shows the uniqueness. Thanks.

Pauls Matuta said...

That is interesting man, one really needs to look at daily activities in order to appreciate the patterns. Otherwise it remains a story book. Keep it up with real life examples.....

M Nuruzzaman said...

Hi John,

Good thinking and a very good habit of following the Bible of Patterns (The GoF book). From my point of view, your solution to the problem has both good and bad sides. Here, I would like to present my view.

Well, it is possible to have an Account Class that will create pin number. As a singleton pattern class should have one and only one instance running at any given time and point, it can maintain uniqueness. In chip and pin card system that can very well be a solution to the fraudulent use of pins. But there is real life problems associated with it. As you might have noticed, a lot of the people forget their pin even after frequent use of their card. I’ve seen some people keep their pin as a Phonebook entry in their mobile phone even if that is highly non-recommended. Now, if a pin is created every week, which will, in my opinion, create mayhem for some plastic users specially who has 4, 5 or more cards altogether (Debit and Credit cards).

Moreover, pins are still sent to customers via the postal service. Hence, there are still chances of a pin to go to someone else’s hand by mistake or by intention (Many times I’ve read in Newspapers that Fraudsters steal Credit or Debit card/pin and Check book from post). Besides, sending pins to customers address each week will cause a lot of extra work for the financial organizations and will go against the Green Initiative (One of the agendas is to use less paper for saving trees) of the Government.

Even though I agree with the use of Singleton pattern for pin generation, altogether, I don’t think it will be a very good solution. I will be happy to discuss this agenda further with you to learn your views about my opinion. Thanking you

Zaman