- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I'm not sure if you're agreeing with the original poster or not.
I think the real answer here is: No, there is no country where all phone numbers start with "0". There may be countries where all DOMESTIC numbers start with "0", or some other subset, so that the zero indicates which subset. But then of course the whole point of the zero is that it is not superfluous, it is telling you that a certain subset applies, and a number beginning with a non-zero indicates that a different subset applies.
My post on this was not intended to make fun of the phone system, but of the poster's statement about the phone system.
Admin
Exactly. When people went from typewriters to computers, many just continued to type the way they were used to, and had trouble making the shift. Even if you told them a dozen times, it's difficult to break long-established habits.
Admin
Years ago I worked for a Political Action Committee. We got printouts from the Board of Elections that were called "walking lists", intended to be used by people who were going door-to-door passing out campaign literature. These were lists of registered voters, sorted by street, within street by odd vs even house number, and within odd/even by the house number. This was intended to give a list in the order that the houses would be on the street, first one side and then the other. (Do other countries use the same convention as the US? That on one side of the street the house numbers are all even and on the other side they are all odd?)
This of course required that house number be stored as a separate field.
They had an additional field for the extra things that sometimes get appended to a house number, like a letter or a fraction. ("101B", "214 1/2", etc)
So yes, there are times when you want to store the house number separately and be able to manipulate it.
Admin
Hmm, then to the best of my knowledge, there are no programming languages that are well-suited for business use. In what language can all numeric types store the number 5 billion? Maybe there are some out there, but I don't think I've ever used them.
Admin
Admin
Wait, Dallas?
Like Dallas, TEXAS?
Ladies and gentlemen, we finally found out the rule has an exception:
INTs are not bigger in Texas!
Admin
Then you will find out that Veekun is not so far off as you suggested.
And you will notice that the author "wvenable" claims that Java supports pass-by-reference.
Admin
Well, having development and production machines with identical configurations eliminates some areas of problems -- like the one brought up here -- but is often impractical.
Like, I probably want to have a debugger running on my development machine to help identify errors, but not on my production machine because it would hurt performance. There may be other applications running on the production server that I don't have on my development server. The production server typically is more powerful than the development server because it has to support more users. Etc.
"Configuration" is a big thing. It is not at all easy to insure that the configuration on two machines is absolutely identical, i.e. that they have exactly the same hardware; exactly the same version of the OS, including all pactches; all the same software, including utilities, software we have purchased, and what we have developed ourselves, etc.
And of course there are some ways in which the production server MUST be different from a development server. We probably don't want the development server talking to the production database server. If we have interfaces to external systems, we probably don't want our development server sending messages to external production system. Hopefully such differences are just a matter of changing some URLs or the like in some configuration files, but not always.
For that matter, if we are supporting multiple production servers, does each developer have to have a separate development computer for each production server that any app he works on is deployed on?
Admin
Smalltalk, for example.
Admin
I said "In what language can all numeric types store the number 5 billion?"
Quoting from http://www.devshed.com/c/a/Python/Data-Types-in-Python/, "A plain integer takes up just a few bytes of memory and its minimum and maximum values are dictated by machine architecture. sys.maxint is the largest positive plain integer available, while -sys.maxint-1 is the largest negative one. On 32-bit machines, sys.maxint is 2147483647." So my statement is not refuted.
Even granting that Python lets you work with numbers of arbitrary size easily ... well, maybe the point of the original writer was that Python is a "good" language and languages that do not do this are "bad" languages.
If so, the bad languages still include the languages used for almost all of the development going on in the world: C, C++, C#, Java, Javascript, VB, not to mention Fortran, COBOL, and assembler.
Admin
I dunno, personally I'd have all numbers as strings. You're not doing math with them, and having them as strings with the appropriate formatting in the database will keep you from having to write PHP code to format them every time you spit them out. :)
Admin
I only know 32767 and 65535 by heart. 31 & 32 bit numbers look so... big.
Admin
Admin
Admin
The world's largest country by population, and many other countries near it, have sequences of numbers as the previous poster pointed out: 1/27 27-365 Subdistrict number within a named district, block number (a 2-dimensional area surrounded by roads), lot number (starting with 1 for some randomly chosen lot in the block, and incrementing as you walk around the block by following the roads either clockwise or counterclockwise). As areas get redeveloped, sometimes a merged block gets two or more block numbers, the lot numbers no longer make sense, etc. Also if a lot contains two or more buildings then you'd better include the building name in the address.
The world's second-largest country by population: No house numbers. Building name, apartment number, floor number, name of street, and name of city.
The US and some other countries: Rural route number. No house number, no street name.
Some of my relatives:
(The above line is null. No house number, no street name, no rural route number. Just the district name and village name. The postman has to know everybody in the district.)
Admin
You could still store it as a number after performing your string-based validation. You'd even only need to store maximum 12 digits, needing 40 bits, since the check digit is redundant for storage. If it is >= 100000000000 then it's an EAN barcode, otherwise UPC and for output you'd just pad out with zeros to 11 digits. After that compute the check digit. (All scanners should be compatible with both. A UPC is an EAN beginning with 0).
All that is only if you care about saving the few bytes of storage. These days I'd call that field VARCHAR and not worry about it. I've seen barcodes much longer than 13 characters that you may or may not need to care about. Some barcodes can even store non-numerals so a string field would be the only solution in this case.
Admin
You're lucky. I still run into it all the time. That and its cousin, the required state that only accepts two characters.
Admin
If you are coerced into doing this you should probably convert the int back into a phone number and check it's the same as the number you intended to store... at least this way when it goes wrong you'll know all about it!
Admin
How about using a language that has working numbers?
Admin
Programming languages which require that developers know and care about the syntax for creating, handling, and closing filehandles are ill-suited for business use. We should make a programming language that implicitly creates files on disk to store data. Variables are read from, and written to, files with the same name. Scope is handled with directories. Files are automatically closed when variables leave scope. Options set when declaring a variable could force file deletion when it leaves scope, or give it an explicit filename that differs from its variable name. In this way we wouldn't have to use filehandles at all, which helps prevent developer confusion. To write to a disk, simply create a variable with the filename and write to that variable. Reading from a disk is easier, just create a variable and it will be initialized with the current file contents.
The best part is that we'd avoid using memory entirely. It would be so efficient!
Admin
Unless they are doing something very dumb, PHP is not the problem:
$ cat z.php #!/usr/local/bin/php
<?php $s = "9895551212"; printout( $s ); $i = 9895551212 ; printout( $i ); function printout( $x ) { echo $x . "\n"; } ?>$ ./z.php 9895551212 9895551212
I'm guessing that they also use MySQL and store the strings as 32 bit signed integers which is where things went wrong. http://dev.mysql.com/doc/refman/5.0/en/out-of-range-and-overflow.html
Admin
Well, from an assembly point of view, there is no exceptions for overflows. Since arithmetic is modular, the CPU will just set the carry flag if the result exceeds the maximum value that can fit in the register. The result might not be what you expect, but there is no actual "error" or "exception".
In some languages, when the carry flag is set, the designer of the language decided to have an exception thrown.
In other languages, when the carry flag is set, the designer of the language decided to return INT_MAX.
Saying one makes sense but not the other is kind of arbitrary and subjective.
In one case, you trap the exception... in the other case, you can compare the result to INT_MAX... either way, you can effectively get the job done.
If anything, many people argue that exception-based programming is something that can lead you down a very dangerous path if you don't fully understand it and you don't know how to do it correctly.
Admin
Admin
XML can be written including a schema, no need to "guess" types.
Admin
Bad idea; oftentimes an optimizing compiler can get things right a good deal better than an experienced low-level language programmer. The reason is that while the programmer may know a few optimizing tricks, he is unlikely to know the same number that are in the optimizing-compiler.
See: http://www.seas.gwu.edu/~adagroup/sigada-website/lawlis.html
Admin
COBOL, LISP, and Ada can all handle business programming. The "weakest" in these according to your criterion is Ada because the LRM allows it to reject programs it can't compile; and if the 5-billion is entered into an Ada program where the compiler is so restricted (think embedded 16-bit processors) that compiler is free to reject the program.
Admin
I was on a 5 hour call when i did support at Microsoft. I forget the initial issue but the problem turned out to be that the guy had named his computer "007" and Windows was plugging that in as IP address 0.0.0.7.
Admin
TRWTF is that the int was silently saturated at INT_MAX. If it became something like -1965481203, the reason would be obvious.
Admin
There was a situation where a change of infrastructure meant that files were suddenly automatically sorted on a print queue by order of size. As our reports were generated: front page, body, back page (in separate files - we had our reasons, mainly to do with mailing packages), suddenly finding that all the front pages, then all the back pages, then all the report bodies generated afterwards, was a bit of a nasty shock.
The solution involved adding a datestamp (in mumeric format) to the filename (in itself not a trivial deal because we were limited to 39 characters, IIRC - yes, it was VMS). The bright spark who came up with the answer coded the date into a number (10 digits). (I can't remember the details of this, or why this solved the problem - it's a long time ago.)
Later that month, on the 22nd to be precise, the report s/w fell over.
Admin
But for a supposedly modern language, C# has an amazing number of features with shoot-yourself-in-the-foot potential. Most of them copied from C.
Admin
Hah, I've done that exact thing, including the 64bit/32bit mismatch. 2147483647 is now etched in my memory for ever.
Admin
Admin
TRWTF is a 'type guesser' -- why not just alter the XML spec and/or DB schema such that each datum must be strongly typed? (Note: I work in a research-oriented digital signal processing shop and have never had 'business' people as clients... I'm guessing my suggestion might be non-trivial with some blighted non-1337 humans involved) Good catch all the same, kudos!
captcha: "enim" for when you need an enum type immediately!