> Today I use VFP to improve my own productivity and distribute my work to a very small community.
>
> Foxite is a great resource for keeping me out of trouble, but someday I know I'll need to hire an expert to make my applications more robust and networkable.
>
> So I direct my query to you VFP consultants in Foxite land: What are the common coding practices that newbies make that I should avoid to make your consulting life easier?
>
> Three things I've heard on Foxite so far
>
> 1. Keep public variables to a minimum
> 2. Use Hungarian notation
> 3. Create your own subclasses of the VFP base classes
> 4. . .
> 5. . .
>
> Are there certain coding practices that make you want to tear your hair out?
>
> Dan Baker
> Effort of the Poconos, PA, USA
Something that I just ran into again yesterday - Always use your own surrogate key field. For example, if you have a ProductCode (something like ABC1234) don't use this as the primary key field. Create your own AutoInc RecordID field in addition to the ProductCode field and use RecordID as your primary key. You can create a candidate index over the ProductCode field, but your primary index must be over your RecordID field.
Your customer has control over the ProductCode field. They can change product codes if they want to. You have control over the RecordID field therefore, management cannot change it - they do not even get to see it.
Use a database container. Free tables are OK for saving data temporarily. For example, if you have a data input batch that you would normally use cursors for and you want to allow the user to save his/her data input batch between sessions. For perminant data, you need to use a DBC. Anything you can do with a free table, you can do with a table that is attached to a DBC. The reverse is not true.
Do use triggers to enforce referential integrity. (You won't be able to do this with free tables.)
Use properly descriptive field names. (You can only use short field names with free tables.)
Use Structural indexes - they open with the table. If you use .IDX or non-structural indexes, you will need to SET INDEX TO if you wish these indexes to remain current. It is very easy to forget one.
Ken
You shall know the truth - and the truth shall set you free. (John 8:33)