Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
If you hardcode user names, you might be a crappy coder
Message
From
07/06/2021 13:12:30
Walter Meester
HoogkarspelNetherlands
 
 
To
07/06/2021 12:21:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01680936
Message ID:
01681056
Views:
43
* a "better safe than sorry" measure -- no matter how careful you've been with design with naming of variables, tables and columns, once you start having "foreign" code or tables, you can't be sure conflicts can't happen.

I think it is the opposite. Let me explain.

In our database all fieldnames are unique because for each table we have a three character prefix + underscore.
The bonus is that wherever you see a fieldname you not only can identify its a field, but also the table where it came from.
It really is refreshing not having to use aliases in joins in SQL statements and really pays of in audit trails as well.

For calculated fields we don't have the prefix, a name without any naming convention. For variables we use a variation of hungarian notation. Possible conflict between fields and variables are reduced to a minimum.

Now the other side. I've already outlined the borderline cases with THIS, THISFORM and VFPs system variables.
But a more realistic problem is the following.

When you are debugging a piece of code, and encounter something like the following
X = ALLTRIM(Zipcode)+" "+ALLTRIM(City)
How the hell do you know whether the intention was to use a fieldname or variable if you're using the same naming convention? Suppose it needs to be
X = ALLTRIM(m.Zipcode)+" "+ALLTRIM(m.City)
How would you know without having to dig into the context of the code? With different naming conventions between variables and it would be.
X = ALLTRIM(Dem_Zipcode)+" "+ALLTRIM(Dem_City)
vs
X = ALLTRIM(cZipcode)+" "+ALLTRIM(cCity)
There is absolutely no question what the intention was.


Now let me give me some real world examples of where 3 party libraries got problems with mdot.

The GDI+ libary. system.drawing.prg. One of the libraries which have applied mdot in the most consistent way.
			m.lhBitmap = This.GetHbitmap(CREATEOBJECT("xfcColor", ARGB_LightGray))
			m.lhBmp = CopyImage(lhBitmap, 0, 0, 0, 0)
			DeleteObject(lhBitmap)
ARGB_LightGray is a constant so has to be applied without mdot, but lhBitmap is not. It clearly is an error. Imagine you have a table open with a field lhbitmap. It would clearly would cause problems.

Bottom line, my point is that mdot creates a false sense of safety.
just make sure the names cannot conflict and you don't have to worry.

Walter,
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform