- 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
Admin
I'm not entirely sure whether you're trolling or not, but this phenomenon has nothing to do with the class of machine in use and everything to do with the expansion and commoditization of programming as a discipline. The more you invite every yahoo in to design your software, the more kludgy and half-broken it gets, and if you won't pay for expertise you deserve it.
As long as there's a demand for more software than top-tier CS experts can develop, there will be plenty of non-experts developing, same as any other industry. Besides cloning, what is your grand solution, oh great whiner?
You'd prefer to keep programming in the hands of the wizards who know what's best for the company, with no tolerance for feedback, and years- or decades-long delays to move to new projects, as the 50's-70's were. Business computers failed not because of the price - look at how expensive current mainframes are - but because the culture was stagnant and rotten.
But all of this is evolution on a huge scale: PC hardware and software evolves over time to become better and cheaper, bad systems eventually improve or die out. Dedicated business systems tend to evolve by stealing the best PC ideas, and then only when threatened by PC competition.
Admin
It's was said once already, but it bears repeating: SSNs are not guaranteed to be unique. They're not unique even if everyone gives you their real SSN, and they won't. It also does your users a disservice when you ask any (or all) of them for an SSN simply to identify them with. Coming up with a unique ID is your job, not theirs.
http://blogs.computerworld.com/node/5969
(Some embedded devices don't support file systems or surrogate keys, so obviously in that case SSNs are the way to go.)
Admin
+1
-10
SSNs are unique only in theory. Additionally, many people have none. It makes for an awful key... if you're using SSN and you haven't yet run into a case where it doesn't work, you've been lucky not smart.
Unless you're trolling me, in which case godspeed.
Admin
Sir, your real WTF is that readers suppose they'll find insightful, informative comments attached to thse articles.
Admin
......There is a special level in Hell dedicated to people like you....
Admin
Yes, this is the real WTF! Keeping such a monstrosity alive is actually Worse Than Failure.
Bonus ending: Someone received a bonus for 'managing' this.
Admin
The original is better as it doesn't leak FileSystemObjects.
Admin
I usually brush off XML errors but this one leapt out and attacked me, too. ;p
On a different note, I am wondering how a database having "not a single stored procedure" means that it is defective. I've got a CMS-style web app I cooked up in Django this past month that seems to be working pretty well, even though I haven't written any SQL, much less stored procedures. Django's ORM seems to be working pretty well so far. Mostly, I'm wondering if you guys have good examples of stored procedure usage that are more than just SQL macros.
Admin
Does nobody use transactions?
Even most of the poor programmers I know use transactions to avoid this problem in their badly-written MAX+1 code.
Admin
Great Scott! They mastered ternary logic! And the Cubs did win the World Series! I've got to get back to 1985 and tell Marty!
Admin
Admin
Teaching opportunity: in "writing applications are boring", "writing" is a present participle; in "writing applications is boring", it's a gerund.
Admin
Admin
Admin
unfortunately that sql code is not uncommon. It comes from offices that have bought into the "use stored procedures for everything, dynamic SQL is bad"
You run into a lot of instances where dynamic SQL in Crystal reports would be easy to do but you have to use a stored procedure, so you have to build the function mentioned.
Admin
They're certainly poor programmers, if they think transactions will make any difference. The problem is simply that if two users run "select max+1" at the same time, they'll get the same answer, and they'll try to use the same 'unique' key on the next insert.
Admin
I'm supporting it now.
Admin
Admin
Further teaching opp: "writing applications" is the subject; therefore the original sentence is correct. Writing applications (e.g., Microsoft Word, OpenOffice Writer, et hoc genus omni) are boring.
Admin
TRWTF is expecting people to read VBScript for laughs. I'd rather poke a blunt fork through my testicles.
Admin
Stored procedures are pre-compiled by the database when they are loaded, while in-line SQL needs to be compiled when it is run; thus stored procedures always provide a speed benefit.
On another note, keeping all code in stored procedures helps make the code more searchable. I work on an application with tens of thousands of files. It is much faster for me to find the SQL I need if it is always in the SQL files (as stored procedures) and I don't need to search the other file types.
Admin
... SQL programmers check result codes, right? Now I'm wondering how much Django is doing for me.
So the time required to fetch a stored procedure is always less than the time needed to compile the SQL?I think I'll be sticking with Django and its compiled-SQL cache for now.
... Wut? Your development workspace is the database itself, and not offline? I hope you have some version control in place. And I can't think of a time when a database search could do something that a good `find` couldn't in about the same time.Admin
Finally, how long does it take to compile a stored procedure? Do you really drive the entire architecture of your projects around the idea of saving three seconds of processor time per day on a database server that is probably disk-bound anyways?
Admin
Should remind you that not all of us are native American writers and that there exists more than one English.
Admin
Admin
Of course, how could we forget about Ungrammaticlish and Typonglish, the other two main branches of English?
Admin
No. Even in this case... no!
Admin
There is no Windows API for "FileExists". The closest is probably "FindFirstFile", which in VB maps to the DIR function, which would be used for the canonical MS BASIC "FileExists" function.
Both the "On Error" and "filesystem" approaches are ugly hacks. Using the filesystem object requires that you create and destroy a filesystem object every time you test: that's going to be slower even than the disk access. Using "On Error" in VB4,5, or 6, creates an Error Object every time access fails. Which is not as bad, but still not useful if all you are going to do with the object is immediately destroy it.
Many of the "VB" examples you used to see at microsoft.com where actually "ASP Classic" examples, and included the explicit destruction of objects, on the assumption that the code would run in a global namespace, rather than in a function. And of course, many people advocate the explicit destruction of objects in VB because they don't know the difference between VB and broken C++.
Admin
Admin
Lotus Notes is ideal for a CMS. You have authentication, a very suitable security model, a document based database, workflow, a web server, e-mail support, choice of programming languages, clustering support etc. etc.
In fact I would say there were few platforms that were better suited.
Admin
] "Function FileExists(f As String) As Boolean "
Is there something actually wrong with that? (Apart from the suckyness which BASIC forces you to add)
Admin
Dangerous, as Dir seqences can't be run concurrently, so if you call that from a loop which scans a directory, you'll get wierd fails.
Admin
Hm, no, pretty sure a Microsoft SQL Server will give back the same "next" number to two callers for all TRANSACTION ISOLATION LEVELS. It might block the insert of one party until after the other commited - but then fail the second one as this ID exists.
So: SERIALIZABLE also does not help here!
Admin
Addendum (2010-05-25 06:32): Of course they used this table to generate every unique id for every table in their system, by keeping a NextId for every table. When only one person was importing thousands of records the speed was acceptable. But as soon as multiple people or processes where importing data, everything would grind to a halt.
Admin
No - it would be correct if he referred to applications that write something or are used for writing (in that case he'd be missing a hyphen: writing-applications).
If he refers to the fact that the process of writing one or more applications, Jay is correct.
Admin
Wow!!! Are you sure this isn't your code??? I'm sorry, but I've written many many great applications in VB6 - and in fact I can say that a very very successful software company that provides real-time trading systems used VB6 for it's extremely rich, fast and flexible GUI.
"Having in-line SQL isn't necessarily bad" - Don't let your boss see that statement - I would fire you on the spot!
Cool Captcha - SALUTO!!
Admin
You seem to believe in fairytales and are bitching about too many things at once. Let me clarify.
Either you complain about indexing performance or select/join performance, because the problems are mutually exclusive. That is, once you've indexed, select/join performance issues due to use of strings will have disappeared. If you don't create indexes, you can't bitch about indexing performance.
That aside, to compare strings, you usually don't have to compare all the characters between strings. String length is usually stored with strings; if string length differs, you've got your "no match" in O(1). All characters only need to be compared in case of a full match. Only in this worst case scenario, performance is O(n). For all other scenarios, just like integers, the strings can be compared 32 (or even 64) bits at a time. In most cases, the first comparison gives sufficient information to move on. So in practice, although there is a difference in performance, it is marginal.
For all practical purposes, the performance of the database does not depend on using strings vs. integers but mainly on proper normalization. If you've got columns like "phonenumber1", "phonenumber2" etc and need to search the database for a phone number, this type of poor design has a much bigger performance impact than strings vs integers.
Admin
Admin
Spot on, except you want FileExists = Len(Dir(FilePath, vbNormal)) > 0
The vbNormal ensures you are getting file, not a directory. It is fileExists, after all.
You can also do:
FileExists =(GetAttr(FileName) <> vbDirectory) which is a bit faster, and avoids odd things that happen when using Dir.
Using FSO is nice, but it's slower (x10) than the native VB stuff.
The idiot who thought it was well designed hadn't considered what happens when yoo do fileExists() for a file locked by someone elseat, and the fact that in VB (& other languages) opening a file that doesn't exist actually creates the file, thus the function always succeeds. Awesome.
Well designed? WTF? Avoid that guys code.
Admin
[quote]
[/quote]The original is better as it doesn't leak FileSystemObjects.[/quote]
It doesn't leak, VB handles that when the routine goes out of scope. Most people put a 'Set ofile = Nothing' in there to be neat.
We ain't talking about C, ya know. I suppose you think it was well designed too.
Admin
Admin
How are SSN's not unique? Unless you're thinking that an illegal alien might be using someone else's SSN.
I absolutely agree that city+state is not an adequate key for a place. There are states where you can have more than one city with the same name. That sort of thing should certainly be considered when you are thinking about natural keys. Almost every textbook ever written on database design points out that a person's name is not an adequate primary key because there could be many people named "John Smith" or "Mary Jones".
I'd be reluctant to use a phone number as a primary key as people change their phone numbers fairly routinely. But suppose we just accepted that and used phone number as a customer id. Then we go global and American-format phone numbers are no longer adequate. I think I'd say, So what? If we haven't planned for going global, then it's likely that we'll have to add or change many columns in the database related to addresses and telephones and currency and probably lots of other things -- like what data do you need to calculate a VAT as opposed to a sales tax and what new data do we need because of government regulations in various countries and who knows what other cultural things. (I once worked for a software house that made a medical office management system. When we sold a copy to a clinic on an Indian reservation, we had to add a field to the customer record for "blood", i.e. how many eighths Indian this person was. 8=full-blooded Indian, 4=half Indian, etc.) To say that amidst all this work we also have to expand our primary key from varchar(10) to varchar(15) would be a drop in the bucket.
Admin
Fred:
Wellllll.... assume the target file is an Excel file that some other user or perhaps, the application itself, has open for reading. The open statement in the function will fail due to a file lock, not because the file doesn't exist.
Why assume that f is an Excel file? Because it often was.
But that's just kid's stuff. How about taking a stab at defending the reports section? Each Crystal Report was pointed at a purpose-built SQL table that was emptied row by row and repopulated row by row and field by field each time the report was called. The original developer had apparently never heard of stored procedures.
Admin
Admin
Yeah, good point. I meant using a stored procedure as the source data for the report, but as you have made plain, I made far too many assumptions about the original developer's capabilities. A stupid mistake, especially since I've actually met him.
Admin
"sdate As String"
I want to be sedated.
Admin
It's the 2 girls-1 cup of code.... You can't unsee it!
Admin
What if the file exists, but is of length zero?
Admin
To do what FileExists is trying to do, I'd use access(); but I don't write VB code.