Proper application design - hardcoded vs dynamic
We have a table, 2 columns. ID and NAME. When our application installs, the script writes 3 records to it in the following sequence: 'Admins', 'Users', 'Visitors'. So one would think, the table data looks like:
ID - NAME
1 - Admins
2 - Users
3 - Visitors
So, when it comes to coding the application, is it better practice to assume that "Admins will always have an ID of 1, so I can write a SQL statement that may reference: WHERE ID = 1 -- These are admins
Or should I be dynamic, where I would build a function called: getIDByName() and you can pass in the name 'Admins' and it will perform a SQL run and return back the number 1. This would mean that when I write the above SQL statement I would say:
.... WHERE ID = getIDByName( 'Admins' ) -- Admins
I have a feeling that dynamic is the better approach, even though it means I'll have to code in more functions to automate it.
