domain model sequence number

末鹿安然 提交于 2019-12-12 06:11:21

问题


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 case 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,
Berryl


回答1:


The 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



来源:https://stackoverflow.com/questions/6236902/domain-model-sequence-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!