爲了創造更好,更一致的約定,我想獲得關於以下選項的反饋。我正在使用的場景涉及記錄一個項目是否運送到現有地址或新的地址。布爾型與更具體的變量
這兩種設置都會得到滿意的結果,但是他們的優點和缺點我沒有想到,或者哪些比較好?
field name: ship_to
option 1: new_address
option 2: existing_address
Pro:
- Allows for new options down the road if needed.
- Easier to grasp what's going on when looking just a the database
Cons:
- Not easier to grasp in the code - have to remember the options
field name: ship_to_new_address
option 1: true
option 2: false
Pros/Cons - Pretty much the opposite of what I listed above.
選項很容易記住 - 做出明智的'N'(新),'E'(現有)。如果需要,FK表(如果有)可以包含完整的「名稱」。該代碼在使用的語言中也將這些編碼爲常量。 '字符串NewAddress ='N''或其他。 – 2011-06-11 18:03:14