-
1. Re: Proper application design - hardcoded vs dynamic
Carl Von Stetten Oct 14, 2013 8:21 AM (in response to Aegis Kleais)Aegis,
Is the "ID" column an auto-incrementing identity column that is controlled by the underlying database? If so, I would err on the side of caution and not assume that the records will be written in the precise order you want. What you might do is query that table once and cache the results in an application scope variable, then query that as needed to get the IDs as needed (saving multiple round trips to the database to retrieve the IDs over and over again.
HTH,
-Carl V.
-
2. Re: Proper application design - hardcoded vs dynamic
Aegis Kleais Oct 14, 2013 8:53 AM (in response to Carl Von Stetten)Carl.
That's an amazingly good solution! I've now modified my Security object to get the 3 most common role IDs dynamically (as well as the 8 global right IDs) and store them into its properties during its initialization. Surprisingly, everything worked FLAWLESSLY on the first attempt. (love it when that happens).
So I'll continue to do things dynamically, but I need to remain vigilant whether commonly called information could be better optimized by storing the data in an appropriate scope. Since the Security object exists in the APPLICATION scope, all the transient requests to it pretty much reference the same data; perfect!
I really appreciate it buddy; thanks!
-
3. Re: Proper application design - hardcoded vs dynamic
Aegis Kleais Oct 14, 2013 9:06 AM (in response to Aegis Kleais)On a side note, I'm kinda proud of myself. I had all these getColNameByColName() methods everywhere and I got into a more OOP-mentality. So I replaced them all with 1 function like:
public any getValueByReference(
required string @tableName,
required string @returnField,
required struct @criteria
)
So I could say: getValueByReference( 'pages', 'id', { 'name' = 'welcome', 'module_id' = 3 } )
And it would look at the Pages table and find a record where the name column = 'welcome' and the 'module_id' column = 3, and then return me that record's 'id' field. Love it!
-
4. Re: Proper application design - hardcoded vs dynamic
Carl Von Stetten Oct 14, 2013 9:28 AM (in response to Aegis Kleais)Glad that worked out!
-Carl V.



