例:
我们利用服务器重建租赁服务。 关于可以租用的物品的信息储存在一张桌上。 每个项目都有一个可以“易受灾”、“被侵吞”或“被打”的国家。 各州都居住在调查表中。
表格:
id name
1 Available
2 Rented
3 Broken
Adding to this we have a business rule which states that whenever an item is returned, it s state is changed from "Rented" to "Available".
This could be done with a an update statement like "update Items set state=1 where id=@itemid". In application code we might have an enum that maps to the ItemState id:s. However, these contain hard coded values that could lead to maintenance issues later on. Say if a developer were to change the set of states but forgot to fix the related business logic layer...
What good methods or alternate designs are there for dealing with this type of design issues?
Links to related articles are also appreciated in addition to direct answers.