- 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
Emphasis added to help you, Ville.
Admin
Not until you're smart enough to quote properly. ;-)
Admin
gapes in horror
I mean, really. It's not 1980 any more. We have real non-mad exception handling which doesn't rely on mad GOTO tricks exposed to the programmer. Err is some sort of magic variable, I assume?
Admin
Otherwise I don't see how that comment would be relevant, considering file not existing is only one of several reasons why file open might fail.
Admin
Admin
Unjustifiable overhead in apps that don't benefit from MVC?
MVC is great, but not always the solution. Using it in Access for example doesn't really work so well. You can separate your presentation layer, business logic layer, and data access layers separately which is still a win. But that's not necessarily MVC.
Admin
Actually, I'll explain in a bit more detail.
The above code is effectively equivalent to more recent syntax:
So basically "On Error Resume Next" means that we don't want to throw error possibly generated by the following sentence(s) to next level, but instead we would like to handle them here.
The next line "If Err Then" is basically the same as "Catch (Ex as Exception)". Err is an object that gets information of any errors occurred after we instructed "On Error...". "If Err Then" is shorter way of writing "If Err.Number <> 0 Then" because Number is the default value of Err object and anything besides 0 is considered true as boolean.
And On Error Goto 0 means that we don't want to handle errors locally anymore but instead throw it to next level. So it's basically "End Try"
I agree the syntax was not nice, but it was generally something a programmer could not decide by himself/herself.
So yeah, I guess in twenty years from now when we've come up with neater syntax someone might look at todays "Try .. Catch .. Finally" block and gape in horror.
Well, I wasn't saying this is something that should be used today, was I? I was commenting about the misconception people have about how OERN was supposed to be used - back in the day when people used languages that had different ways of handling errors than what we are used to today.Saying OERN is only good for ignoring errors is just as sane comment as claiming that Try Catch is only good for ignoring errors. Sure, both can be used for that, but neither are designed for that.
Admin
It has been a long time since I have done VB coding, but if I remember correctly On Error Resume next had some practical purposes.
I think one of the most common purposes was dealing with pulling items from a collection or seeing if an item was in a collection. If I recall correctly, one of the best ways was to set On Error Resume next ant then access the item as if it was in there. If there is an error then it was not, if there is no error than it was.
Admin
I can name 3 off the bat:
Still I think it makes the most sense for nearly every business application out there.
Admin
The trouble with MVC in web applications is that it's never done right. Hint: if your controller is server-side, then you're doing it wrong.
MVC is about user interfaces and event loops, not program organization.
Admin
Sorry. Buy yourself a real test engineer, and he'll automate this joker out of a job in a few days. Test is harder than design, people.
Admin
This wins the Tin Foil Hat Award for the most entertaining defence of the indefensible seen so far. Or for trolling. Or for sarcasm. Any which way, it's superbly tin-foily.
(Lose the green-grocers' apostrophe, btw. An opportunity to exercise my inner Grammar Nazi as well ... can life get any sweeter?)
Admin
I never was into the whole brevity thing.
Admin
Always refreshing to see the amazing level of penis fencing in the comments.
As has been pointed out by several reasonable people, On Error Resume Next had quite legitimate uses in VB6 and prior. One might prefer to check for error conditions in-line in certain situations rather than construct a series of complex error handlers (leads to spaghetti) or having a catch-all handler try to figure out the context. Remember good ol' fashioned ANSI C?
Admin
I'm working on a reference book which I think might be valuable to many aspiring mathematicians: A List of Even Primes (Abridged Edition).
Admin
That's not a greengrocers' apostrophe. It is acceptable to use an apostrophe before a plural "s" in cases where this removes ambiguity. I would include compiler keywords in such cases.
http://en.wikipedia.org/wiki/Apostrophe#Use_in_forming_certain_plurals
E.g., in a code review, I might say "consider replacing all of your fget's with fget_s" and I would heartily defend that apostrophe to the core of my eating-shoots-and-leaving being.
Admin
When I'm interviewing people for jobs, I give them a sample of code that I've written. If they immediately fall to their knees and shout, "You are a programming god! I am not worthy to study at your feet, but please allow me the privilege of basking in your glory!" then I conclude the person should be hired. If they presume to find flaws in my code, I order that they be immediately killed.
Admin
Um, you did ask what it depended on.
The interviewer's answer, though not especially informative, is fairly close to correct. 1 is "prime" if your notion of "prime" is "non-negative, non-composite integer."
The more forthcoming answer is that 1 is better than prime - it's the multiplicative identity (or a "unit", for those versed in ring theory.)
The interviewer was probably less interested in whether you printed 1 than if you did other things... like use the inequality
Pn < n ln n + n ln ln n (for n >= 6)
to do a Sieve-of-Erastosthenes solution for speed...
or some other approach for memory...
Most of the "code interview" is tackling the problem. Surprisingly little is actual code.
Admin
I can think of lots of drawbacks of MVC, like for starters, by splitting code across three modules, you can make it more difficult for a reader to see the flow.
I'd be hard-pressed to think of any programming technique that has absolutely no drawbacks. Someone who says that he cannot even imagine any situation where a given technique would be a bad idea is admitting that he either doesn't understand all the implications of the technique or that he doesn't have much imagination. Database normalization? Excellent idea, but surely we all know times when denormalization can simplify code or improve performance. Data hiding? Sure, but sometimes a variable is used in so many places and is so obviously generic that a public global is preferable to passing it up and down every parameter list in the system. Etc.
Admin
This is a terribly important question.
(e) I'm guessing here, because Wikipedia is renowned throughout the academic world as an incorruptible authority par excellence -- and, of course, a simple URL link to such a treasure trove would immediately lead me to your point -- that you are referring to the following comment:
"The apostrophe is often used in plurals of symbols. Again, since there can be no misreading, this is also regarded[who?] as wrong.[23] That page has too many &s and #s on it."
You will find my answer to your assertion somewhere between your upper thighs and your lower abdomen. Don't squeeze too hard. Somebody might be listening.
Admin
One definition of even number is that it has integer factor 2. This naturally leads to certain limits on how many even primes can exist.
If your book becomes succesful you should consider sequel called A List of Primes With Integer Factor 3 (Abridged Edition).
Admin
Oops, bad example (the function name is fgets) - make that "Consider replacing sprintf's with sprintf_s'es"
I was actually referring to this: "An apostrophe is used by some writers to form a plural for abbreviations, acronyms, and symbols where adding just s rather than 's may leave things ambiguous or inelegant."
Adding just s to a compiler token creates a different compiler token. Adding 's makes it clear that the thing preceding the apostrophe is the term, and that the s is not part of it.
Admin
How'd you get in then? Oh wait, you do know it all, despite the insistence that Hungarian (or similar) notation isn't an idea that should have died long ago.
Admin
Trivial to pronounce for some, for you maybe (or Top Cod3r). You can easily say "Gyagyás vagyok", right? "Mit sütsz, kis szűcs? Tán sós húst sütsz kis szűcs?"
Let's then start the flame war over "Asiatic" languages: Hungarian belongs to the Finno-ugric subfamily of the Uralic family Turkish is a prominent member of the Turkic family.
Bring it on!
Admin
If you are old, 1 is a prime. Basically, a bunch of mathematicians decided that for certain proofs to work they had to change the definition of prime numbers. I call that cheating; 2+2=5 for large values of 2.
Admin
Changing an arbitrary definition to another arbitrary definition in order to make rest of the things simpler is not cheating in my opinion.
The "certain proofs" you are referring to would work even if 1 was considered prime, their wording would just be a bit more cumbersome.
Admin
They actually had the chance to hire The Doctor, and they missed out on it!
Admin
Why do all the calculation if others have done it before you?
CAPTCHA: ratis
Admin
Admin
it's different for everybody, i used to do this until i found that everybody was using different prefixs, so i just use suffixes now like SaveButton, NameTextBox, etc, its easier to remember the control/variable and i can choose the correct one (if there is more than one type of control with the same function, i.e. NameTextBox and NameLabel), using Intellisense that is.
my 2cents, take it or leave it.
Admin
Gosh, I forgot to mention the Nazis, didn't I? Naughty me. It's so obvious that I was associating Magyar and türkçe from an Aryan Nationalist point of view.
Luckily you caught me at it. Silly me. I thought I was just talking about non-PIE languages, and assigning two of them the vague epithet of "asiatic."
Love to know how the evidence is thin and polluted with racial prejudice, however. Even though I didn't mention it, and it's not remotely relevant to the fact that Turkish and Hungarian are not PIE, and I wasn't suggesting in any way, shape or form that Hungarian and Turkish share a recent common root; nor to the fact that both languages are pleasingly pronouncable (unlike, say, English), but ... Uralo-Altaic is a genuine and reasonable approximation for a linguistic group.
I call dickhead.
Admin
I try to avoid it if there's any alternative recourse, however.
The basic problem is that you and I are two amongst six billion people, many of whom speak English, and many of whom speak English as a second language. Misuse of the apostrophe is easy, because it's practically universal, for understandable reasons of convenience. But why stop there? Why not mangle any other part of language.
Permit me once more to introduce my friend Larry Trask, who is far better qualified on the subject than I.
Admin
And here you come to one good reason TO use HN...
So, you're not using HN, and you change
int Value;
to
long Value; (easy, see, so why not do it?)
Now, suddenly you get errors all over the place, for instance data persistence to binary files breaks, database storage problems occur (SMALLINT fields no longer work, and NUMERIC(5) fields do strange things), you get weird mathematical errors (long x = (long)Value * 50000) and so on.
Having HN would at least make you think hard about changing the type of a variable without having tests in place.
Admin
The "importance" of naming your variables with a prefix that tells you what type it is? Do you mean the low-level data type? If so, that's a horrible idea, and it has been denounced many times. What if you need to change the type of the variable, do you rename it everywhere it's used?
Admin
Pedantry in honor of Dennis Leary. Couldn't resist.
Admin
Stargate Featurette
http://stargate.mgm.com/specialops/link.php?urlid=9&id=5924
An Official Stargate Special Ops Member
http://stargate.mgm.com/specialops/link.php?urlid=10&id=5924
An Official Stargate Special Ops Member
Admin
That no one might see down into my depth and into mine ultimate will--for that purpose did I devise the long clear silence.
Many a shrewd one did I find: he veiled his countenance and made his water muddy, that no one might see therethrough and thereunder.
But precisely unto him came the shrewder distrusters and nut-crackers: precisely from him did they fish his best-concealed fish!
But the clear, the honest, the transparent--these are for me the wisest silent ones: in them, so profound is the depth that even the clearest water doth not betray it."
--Nietzsche, Thus Spake Zarathustra
Admin
Your variables are directly accessible from files they're not actually defined in?
You are the obvious master of encapsulation and scope.
Admin
So basically that article is saying that... It depends.
Admin
Let me get this straight - you don't know what Euler's identity is and consider yourself as have "excellent" math skills. Please tell me your a high school student.
Admin
It's probably for a job with an encryption company.
Admin
Considering the standard of education these days, some people may not.
<< slaps hand to forehead
Oh no! I'm turning into an old fuddy duddy!
Admin
There is nothing intrinsically wrong with using On Error Resume Next, if you handle errors. The problem is that too many VBScript/Classic ASP "programmers" litter their code with OERN, and then don't even bother to continuously check for errors, they just happily code away.
Try dealing with over 1,000 ASP files, all of which use OERN, and trying to track down bugs in it. It's not a simple matter of just removing OERN, because the code doesn't work without it, due to the original programmer calling methods on objects before they're created or referencing variables that don't exist.
It's a freaking nightmare. I could deal with it, if it was only done properly and not used as a crutch.
Admin
I think it was the Doctor's daughter (see Season 4 of the new set of Dr Who) as the Doctor would have got 100% first time and re-wrote the test to confound a Dalek so that he could deal with it. ;-)
Admin
I'm not going to get into an argument about the merits or otherwise of any platform, OS, etc, as my point is separate to that.
If your employer has UNIX at work then you write scripts compatible with that, if your employer has Microsoft products then you write scripts compatible with that, if your employer has their own architecture...
Admin
I note he lists this sentence as correct:
It is very bad style to spatter e.g.'s and i.e.'s through your writing.
He's doing the same thing as I am, just for literary jargon rather than technical jargon.
Admin
The prime number one is really a trick queston -- it's impossible since there are complex numbers that are prime (Gaussian Primes) and Complex numbers are not ordered.
Admin
Quite simply your knowledge of maths isn't excellent. e^i*Pi=-1 is highschool mathematics.
Admin
Admin