- I use enums for column ids for a grid control. I get to say "grid.col(cols.thisOne)" instead of "grid.col(2)". Easier to read, easier to change, and it forces me to fix them on refactoring (more on this in a later article).
- When I have a stored procedure return more than one table, I will use an enum to index the tables in the dataset. Again, I get to do "ds.tables(products.sold)" instead of "ds.tables(1)".
- A more esoteric thing I like to do is when using datatables, I'll use an enum with "tostring" to reference the datarow. So I'd have something like "row(taskData.client.tostring)" ("taskData.client.tostring" evals to "client") instead of "row(5)". Again, this is more readable, and it forces fixing.
When I make an enum, I know exactly how it's going to behave. It's kind of like a super constant in that respect.
I'll talk about force-fixing in my next post.
No comments:
Post a Comment