Software Development
Blogs and Discussion
developer.*
Books Articles Blogs Subscribe d.* Gear About Home

Thoughts on IsDate() and Arguments as Locals

Dan Read posted an article containing IsDate() and IsNumeric functions for VB.NET and C#. I had the following thoughts in response.

The old IsDate was American English-centric.

The Tryparse replacement is also American biased, I believe.

For example, Europeans may enter the date as 25/12/06 for Christmas day.

They think it's more logical to be here "little endian" where a "big endian" date would be 6/12/25 and the American practice, of mm/dd/77 is middle-endian.

Two American standards, the way in which we enter dates and the Imperial system of weights and measures (Fahrenheit and not Centigrade, kilometer not mile) are in fact strikingly at variance with practice elsewhere.

A world date parser is needed, clearly, that would use Backus Naur Form to recognize, insofar as is possible, different date styles.

One problem would be the use of calendars other that the Gregorian calendar, a Christian artifact.

In transitioning out of VB, we have to unlearn cozy practices that reflect American domination of computing circa 1964.

Even IsNumeric is culturally biased.

What's a number? What if the user spells out the number in words, or enters Chinese characters?

I suppose one could write raw input parsers, one for each language and culture, but then you'd be reinventing common concepts.

Clearly, we need world government. We fantasize that we live in economically competing economic communities and can "win" wars by forcing Visual Basic based standards down the supply chain, but we cannot.

I think I'll let the previous paragraph stand. Too many programmers are pawns in corporate wars in which one corporation is trying to "win", not by making a better product, but by locking in his supply chain to Macola, SAP, SQL Server or what have you.

Akin to the ugly "English only" movement in the USA, it's an attempt to get something for nothing: a built in advantage based on not being innovative as regards the way you do business.

Therefore we have to be careful IMO about wrapper functions that give us what we think is the old "functionality" when the intent of the old functionalty was DMMT ("Don't Make Me Think", and ugly book that sells way better than mine, boo hoo).

Fortunately the world computing proletariat is developing Open intercommuncations protocols. They accomodate .Net, reluctantly, but not Visual Basic functions that make you reject what to an Englishman or Chinese person might be a sensible date.

Also, on the topic one of the techniques used in the code, namely treating a by val input argument as a local variable: In all versions, anyString is assigned a null string when it is Nothing (VB.Net), that is null (C Sharp).

This is a bad mistake, although it "works".

In C Sharp, parameters are passed in the tradition of C by value, where a copy of the value of the parameter is made on the stack. This copy can be changed but changes are lost.

In Visual Basic the same thing occurs when you pass ByVal, or (since the dawn of VB.Net as opposed to VB COM) leave out ByVal or ByRef.

This means that the code "properly" alters a null/Nothing value to the empty String.

But then in a global sense, your program reader cannot use "hmm, passed by default or explicitly ByVal" to infer, as regards your code, "hokay, won't need to change the parameter for any reason".

The change then made in the above code violates this mental Contract, and it isn't necessary.

When accessing the value of the parameter use

anyString == null ? "" : anyString

in C Sharp: use

Iif(anyString Is Nothing, "", anyString)

in VB.Net.

The latter code "wastes" time in stacking and evaluating anyString unnecessarily.

Boo hoo.

Any code is member 0 of a fuzzy set of related code that was hacked from member 0. To put in a violation of the mental contract that will be made with the alert maintenance programmer (who as a Good computing Guy, will equate ByVal roughly with read only while being aware that who knows what lurks in the hearts of men) *ab initio* and with so little necessity creates an Original Sin.

Trivial? "De minimis non curat lex"? Give me a break. News fa lash: the job of the computer programmer is to bovver with the trivial in order to free the owners of capital so as to improve their golf score, and I take this seriously despite my issues with the owners of capital, as part of Human Dignity.

Any questions?

Categories:  | |

User login

About our advertising.

Atom Feed

developer.* Blogs also has an Atom feed, located at this url.

Click here for more information about Atom.

A Jolt Award Finalist
Software Creativity 2.0
Foreword by Tom DeMarco

Recent Posters

Based on most recent 60 days, sorted by # of posts and name.

Google
Web developer.*

Who's online

There are currently 0 users and 20 guests online.

Syndicate

Syndicate content
All views expressed by authors, bloggers, and commentors are their own and do not necessarily reflect the views of developer.* or its proprietors.
Click to read the Copyright Notice.

All content copyright ©2000-2005 by the individual specified authors (and where not specified, copyright by Read Media, LLC). Reprint or redistribute only with written permission from the author and/or developer.*.

www.developerdotstar.com