Hahah . . a major can 'o' worms!! Good coding practice is something you learn as you work, and learn from books, and learn from inspecting others code as well as your own.
It's really done to make it easier for you and other programmers to go back and understand what you've created and be able to pick up where you left off quickly. It makes it easier to comment code, because the code can do some of the talking for you instead of reading verbose comments. IMHO, it looks cleaner, though is often longer. The increased length is the main reason many programmers don't do it a lot or at all, it takes too long to type it out and they figure "Why? The compiler will know what I mean..." Which is often correct, but it's not for the benefit of the compiler, it's for the benefit of others inspecting your code.
Basically what I try to do to follow "good coding practices" is always declare variables, use descriptive names, put clues to what kind of variables they are. For instance, strMyVariable you know is a string right away but what if it were called MyVariable, now you have to go back to the declaration and find out what kind, well what if it's not declared?? Then you've got no idea! It makes it harder to troubleshoot. This BTW also applies to table names, query names, form names, control names, everything! I personally use the Reddick VBA naming/coding conventions (
when designing db's and writing code. It takes extra time, but pays off when you or someone else has to work on the project in the future, and helps in development because you have meaningful names instead of the access Table1, Query1, List1 crap.
The other things I try to do is use proper syntax, there are many shortcuts to referring to objects. Pick one and stick to it, some programmers go in between the different ways to refer, they'll use:
[tt]Me("ControlName"

[/tt]
one minute and then
[tt]Me.ControlName[/tt]
the next. Not a big deal, just when you see the two it makes you wonder "Is there a difference?!"
And one of the other things I try to do is always put what I'm testing for down explicitly and supply all arguments, even many optional ones. Many function return True/False. Well for many functions when you put the function not followed by "=True or =False", True is assumed. While this works, it's not very clear. IE:
[tt]If IsNull(x/y)=True Then[/tt]
instead of
[tt]If IsNull(x/y) Then[/tt]
it's longer yes, but it's easier to understand what's going on. Some functions may default to false so then you're left wondering is this a false function or a true function? By always putting it in, necessary or not, you know right away.
There are many other things, but these are some of the bigger things I try to achieve when coding. Others will differ GREATLY in opinion on this. You'll start to see where you falter in this when you review your own code against others. Most books subscribe to the convention above, and from the examples in them you'll start to get an idea of "good coding practices". They don't come overnight, they do increase development time, they do make your program easier to understand, fix, & troubleshoot. Take it or leave it, hopefully that helps! Joe Miller
joe.miller@flotech.net