domain model sequence number
I have a need to assign the next sequence number for a Project according to a given prefix code. So you wind up with alternate id numbers like PROJ_ABC_001, PROJ_ABC_002, PROJ_XYZ_001, PROJ_XYZ_002, etc.
While this need is quite specific, I would suggest that there is a more general and common ca开发者_JAVA百科se where businesses use alternate ids that are sequential integers in order to identify different Customers, Projects, Orders - whatever.
Of course these aren't primary keys in the database. And while databases are a logical place to maintain and generate a sequence number, only the application knows the specific rules of a given use case.
Have you ever treated a sequence number as a domain object in an application? Can you suggest any design pattern(s) to do so in a multi-user environment?
Cheers,
BerrylThe closest answer I found here was along the lines of the accepted answer for a related post.
That posting is much more NHibernate specific than I'd like, so this is a half-hearted answer. Love to see a more technology agnostic (ie, design pattern) type of answer.
Cheers,
Berryl
精彩评论