Generating unique strings in Agile Platform - Web Development - Techguide

Generating unique strings in Agile Platform

 

Summary

The OutSystems Agile Platform makes it a snap to create random strings. Justin James describes using the platform to create strings for a password reset system.

Events

Echelon 2012
June 11 and 12, 2012

University Cultural Centre, National University of Singapore

Startup Asia Jakarta 2012
June 7 and 8, 2012

12th Floor, Annex Building, Wisma Nusantara Complex, Jl. M.H. Thamrin No. 59 Jakarta 10350, Indonesia

MMA Forum Singapore
April 23-25, 2012

Grand Hyatt Singapore

Something that comes up from time to time in my projects is the need for a very random string of numbers and letters. In an application that needs something like this, it's easy to think that you can count on using a long string to ensure uniqueness, but I've always felt that this was a dangerous assumption, particularly in an application that scales. In my projects with the OutSystems Agile Platform using my SaaS Framework, I found the need for this in more than one place, so what I've done is made a simple system to give me random strings that are sure to be unique.

You may be wondering about the uses of such a system. In my SaaS Framework it is a core piece of the password reset system. It sends an email to the user with a unique string in the link to complete the password, which is used to identify the request, and validate things like who the user is, and that the password reset request has not already been completed. In such a situation, it would be a major security risk to send out an easily predicted identifier. I also use the system for providing unregistered users access to a restricted piece of information, such as emailing a customer a quotation for work to be performed. Again, this is a situation in which you cannot afford to have the data identifier be predictable, but at the same time you cannot validate the user's identity.

Creating the strings
Agile Platform comes with a "GeneratePassword" function that creates the strings for you. It accepts an Integer to specify the length and a Boolean that allows you to have it return only numbers.

In order to make sure that the results are unique, I created an Entity called UNIQUE_STRING to store what was already made. Next, I made an Action that accepts a length and a Boolean flag for numbers only. The Action runs GeneratePassword passing in the matching input parameters, and then checks the database to make sure that what was created is not already there. Once it has a unique entry, it adds it to the database, and then returns the ID of the created Entity.

I chose to use the ID of the Entity and not the actual value for the Action's output because I want the consumers to have the option of deleting the entry if it is ever appropriate. For example, in a situation where the string identifies a temporary or disposable item (like a filename), then it makes perfect sense to get rid of it when you are done. After all, why have a database filled with data you will never need again and has no business value?

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment

ZDNet Asia Live

Kodak loses patent ruling against Apple, RIM. http://t.co/N1j7aZ6o

#radio Radio Serbia by EnjoyIT 1.0 http://t.co/nGQFvX2E

Rise in <b>Chinese</b>-funded acquisitions could trigger more hurdles http://t.co/0pXBS1HR

Rise in Chinese-funded acquisitions could trigger more hurdles: By Ellyne Phneah , ZDNet Asia on May 22, 2012 (6... http://t.co/W3SOdw2c

RT @zdnetasia: CFOs increasingly involved in IT investment decisions. http://t.co/8QrfwOSb

CFOs increasingly involved in IT investment decisions http://t.co/XD1LerFq via @zdnetasia #PrivateCloud #SC2012 #CAPEX

Rise in Chinese-funded acquisitions could trigger more hurdles. http://t.co/VC3G3m3o

RT @zdnetasia: Rise in Chinese-funded acquisitions could trigger more hurdles. http://t.co/VC3G3m3o

So much as we know , MTK6575 extremely integrated frequency1GHz ARM Cortex-A9 processor, the superiority of 3G / HSPA Modem, and help the...

1 hour ago by y15822137359 on 5 SaaS adoption speed bumps to avoid

Rise in Chinese-funded acquisitions could trigger more hurdles - ZDNet Asia: Rise in Chinese-funded acquisitions... http://t.co/bZaAQnRL

Rise in Chinese-funded acquisitions could trigger more hurdles http://t.co/mIsuZjnU http://t.co/erFX4aVv #arcavir

http://t.co/VNaZtseV Rise in Chinese-funded acquisitions could trigger more hurdles: "Cash r... http://t.co/N0gZZEdR http://t.co/wiqY9ktt

Rise in Chinese-funded acquisitions could trigger more regulatory clearance issues overseas http://t.co/cvLSpTwo #in

Alibaba seeks $2.3B from shareholders for Yahoo deal. http://t.co/qLRAhRQk

CFOs increasingly involved in IT investment decisions. http://t.co/8QrfwOSb

Quickflix WatchNow 2.0 http://t.co/XWti5VWT

I reckon your view: "CRM is strategy, not software", if a company replicating the approach uses in ERP implementation into CRM, what they...

1 day ago by wykoong on Gartner: Mobile CRM gives better ROI than social

This video will teach you about the Excel fill handle but also provide you with a workook to download... http://www.youtube.com/watch?v=...

1 day ago by TradeBrother on A quick fill handle trick for Microsoft Excel

waiting...

3 days ago by eapete on What should count in a company's market value?

Boy, you've opened a can of worms now.

Wait for the rants & raves.

3 days ago by eapete on What should count in a company's market value?

I was puzzling before this whether to replicate the success formula we executed for a financial institute, and come out with a standard s...

4 days ago by wykoong on Drop the egos, copy ideas, then innovate