ID generator

1
2
//Actualizacion: 15/04/16:
//Dos modos distintos para generar IDs.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
It's very simple, is a id generator. A number combined with characters array. Mostly used for keys and unique IDs.

2 Responses

It's a very cool homemade id gen :). In java you can use UUID either https://docs.oracle.com/javase/7/docs/api/java/util/UUID.html if the project permits.
Just a little ideia in code pattern matter, I'd just change the constructor to private e make generateId a static factory (Bloch, Effective Java).
i.e.
public static Id generateId(int logitud){
Id id = new Id(longitud);
id.idArray = new String[logintud];
....
return id;
}
this helps to build more semantic sentences :D i.e. Id.generateId(10);
Just an ideia (I like to share and discuss code pattern stuff hehehe):D
Best regards!
Hi Kim :). Thanks, now it's updated and tested. And, yes, this code your help to make semantic sentences. I'm using for create UNIQUE id for database with 500 registered persons. Regards!

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.