Computer Learning Zone CLZ Access Excel Word Windows

You have to learn long division because you won't always have a calculator in your pocket!

-3rd Grade Math Teachers in 1980
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
Home > Forums > Captain's Log
Back to Captain's Log    Comments List
Clever Code Upload Images   Link   Email  
Richard Rost             
2 months ago
What I've been saying for years...

Clever code is probably the worst code you could write
Thomas Gonder       
2 months ago
I've come to take exceptions to some of the advice from the "style" experts. Yes, writing one long line of clever code is... um dumb. There's some I still haven't figured out how they work, despite being quite elegant. I chalk it up to lack of time, reason to know or ability.

Years ago, a style for naming variables in VBA was proposed by two guys, Leszynski and Reddick, if I remember correctly. They proposed something similar to one my professors some two decades earlier. However, another professor who had lots of experience with code (before the 1970s) balked at my code saying "You don't need to know this is an integer, that's why we declare it above, you're much better served by a few letters that serve to explain HOW the variable is being used."

For example, we could  say "Customer" but if you name it "tblCustomer" doesn't that eliminate a lot of confusion? That's a valid use of a prefix to me, but saying strName means what exactly? Clearly a name isn't going to be a decimal typed variable.

I use "w" to indicate "work", as in I'm building a variable to do something, not just data pulled from a table. For example, wCustNameFull tells me that I'm doing something (probably concatenation with trimming) to stick all the parts of a name together from different fields. Likewise, I tend to use an "a" in front of a variable to indicate this was an argument passed to the procedure (via a parameter). Instantly I know the data came from some other procedure and that I better not mess with it. If I see something that be like a variable in my code, but it starts with a "f" or "s" then I know immediately that it's a function or subroutine, and not a variable. The end.
Sami Shamma              
2 months ago
Simple Code over clever code every time.
Richard Rost             
2 months ago
Yeah, I've never really needed prefixes on any of my variable names because most of them are obvious and straightforward, like you said: FirstName, LastName, CreditLimit, those kinds of things. The main reason why I started putting T, Q, F, and R on the end of my Access objects like CustomerT, is because way back in the day, whenever you were using a wizard to try to create a combo box, for example, and it asked you where you wanted to get your data from, it didn't separate them into tables and queries. So if you had a table named Customer and a query named Customer, you were shit out of luck, LOL.

So that habit stuck, but it's also nice because sometimes when you're dealing with record sets or more advanced objects, it's handy to know whether the data source is coming from a table or query. It's also nice at a glance when you're looking at form properties. So I'll be keeping that habit, and I'll still teach that in the future because I think it's handy. But as far as true Hungarian notation for variable names, I've never needed that stuff, and I build some pretty elaborate programs.
Alejandro Juarez      
2 months ago
Richard, I suspect you probably meant "if you had a table named Customer and a query named Customer, you were..."
Richard Rost             
2 months ago
You are correct. Edited. Thanks.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Captain's Log.


The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.

Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
My Account
My Courses
Lost Password
Student Databases
Change Email
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Customer Support
Web Site Tour
Consulting Services
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Video Tutorials
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Terms of Sale
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/15/2024 4:21:54 AM. PLT: 0s