- 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
Uh, if you're using ASP and "Access" you're not using VBA at all, since if you're using ASP, you're using "Access" for the database engine only, i.e., Jet/ACE, and not using the VBA scripting capabilities.
Admin
So, exactly how would you go about writing a point-and-click application-building system where you let the user create UI components without asking them to name each one explicitly?
You wouldn't do that? OK, that might be a valid design decision, but it might lose you users. That's debatable, of course, but MS decided it would supply default names for the users as a way of being user-friendly. You may disagree, but that's what they decided to do -- what simpler way to do it than this?
And thinking there were 696 command buttons on the form is something only someone who's never used Access would assume. What 696 means is that this is the 696th control added to the form. Open up Access and try it yourself -- add a command button to a blank Access form, and it will be named command0. Add some other objects, then another command button, and you'll see that its number is not command1, but commandN where N is the 0-based counter of the number of controls added to the form since the form was created. Add a text box with a label after command0 and then add a second command button and it will be command3 (1 and 2 being the textbox and its attached label).
How would you design this if you chose as a design goal supplying default names for the controls?
It might seem that the real WTF here would be that the form has had 696 items added to it (removing controls does not decrement the control counter, and there's a hard limit of 700-odd controls over the life of a form). But I just checked one of my older apps (it began life in 1997 and has been upgraded and enhanced signficantly since then), and the counter on it is above 600, so that isn't even what I'd consider a big deal -- it's just evidence of a long development lifespan for the particular form in this particular application.
Admin
VBA has a WHILE LOOP, and it did even when it was called Access Basic.
Admin
Er, no, it's just the default way Access forms work in terms of generating names for controls added to a form. The 696 is just the counter of how many controls have been added to the form since it was first created. Over the long lifespan of an application (I maintain Access apps that originally date to 1996 and Access 2, for instance), a complex form can easily accumulate that number of controls when you consider that every element on an Access form is a control (a textbox with its label is two controls; an option group with a frame, a label and three options, each having a label, is 9 controls), it's not at all far-fetched for the counter to reach 696.
Of course, there's a hardwired limit of 700-odd controls over the lifetime of a form (even if you delete them), so this form would likely need to be recreated sometime in the next few years if it were to continue to be developed.
Admin
Each control type does not maintain a separate counter. The counter is for all controls on the form. So, it's 696 CONTROLS of ALL TYPES, rather than 696 command buttons. With the 700-odd hard upper limit for controls added to an Access form over the entire lifetime of the form (deletions don't decrement the control counter), a form with 696 command buttons likely wouldn't have much else on it.
Admin
Execute Command 696: Kill all the Jedi
Admin
TRWTF: VB (nothing else really matters)
Admin
They've never cared for what they do.
Admin
While yes, it's a whole lot of rules and direct error handling / reporting, it doesn't look like it's something unovercomable ('something that cannot be overcome', my engrish suxx). It lists a number of conditions, which can easily be extracted into single conditional rules. The reporting of the errors as well.
Admin
Admin
That reminds me about the worst teacher CS101 EVER*, who not only ditched me about writing a crazy IF-with-no-ELSE but also cut half my grade because of that...
1 min reading the code 2 min reading the code ... 10 min reading the code
"Hummm, better if you do by my example."
Crap and I thought I was in the class to learn something!!! I learnt copy-paste instead.
Admin
As for the WTF, it seems a slightly imperfect but frankly real weight and balance app. Those 'magic numbers' are real magic numbers given by the manufacturer.
And as for re-writing from scratch based on the req's document the client gives you, gotta be honest, that doesn't show a lot of real-world experience...
Admin
If ttload>0 then this code will fail - unless the language you are using automatically sets all uninitialized integer variables to 6.
Admin
Yawn
Admin
So a case of the "look at the code and see what it does" spec. Nothing new, pretty standard in fact and I've had enough of them in my time to work and really cannot be bothered looking at that code to see what it does.
The new approach of "test-driven development", i.e "look at the test code and see what it does and that should give you an indication of what you need to do to make them pass" is perhaps an easier approach but still totally inadequate.
Perhaps approaching "QA" which in most places I have worked means the testing team, although QA isn't equivalent to testing, assuming they have one, can be the best approach because they have the best idea as to what the specification is, and may even be able to give you access to the list of tests they run, from which it might actually be easier to write a spec, which is what you should do before you rewrite, and not just dig straight into the code.
Admin
You are throwing out knowledge if you throw out readable documentation (for which I will accept well written code). Unreadable code isn't years of accumulated knowledge, it's the product thereof. The knowledge itself is already lost if you have to dig in to the (bad) code in order to retrieve especially since the person doing the digging will most likely not be a business domain expert but a programmer.
In fact, this in and of itself could be the impetus for the rewrite. The more maintenance a program needs the more expensive it gets. If you can't let go of your app because of lost requirements which are only in the code then you may well have a big problem. In the future you may be forced to a rewrite because of hardware/software/reality updates. The sooner you stop making poor undocumented code the less painful that process will be.
In the end you have to do a cost benefit analysis. Not only will you give your manager a happy feeling, you may actually learn something. Don't take a position of always rewrite or never rewrite. Both are unrealistic extremes and if you take either position your arguments will tend to be stock answers rather than suited to the situation.
Admin
++1
100% endorsed. Rewriting is a skill to be learned.
As a strategy, it is far, far safer to repeat the existing implementation bugs-and-all than to start again from a (figurative) blank sheet. Because when it comes to testing, you know whether you've done it right - because the new program matches the old one.
During the development phase, you are going to be able to make a note of all the bugs you encounter along the way and it may well be worth your while correcting them. In which case, you document this in your test cases: "This won't work the way it used to because I've fixed the bug."
Believe me, I know - I've made a lucrative career out of successfully bringing legacy apps into the modern world.
Admin
Admin
I never cared for what they sayeye.
Admin
Admin
Admin
The sad fact is that the easiest apps to rewrite are the ones that are written well, i.e. nicely modular with low coupling so you can rewrite one module without breaking too much else, and nicely clearly written so you can see exactly what it does.
However those are pretty much the apps that don't need rewriting because they are nicely maintainable.
The ones that you want to rewrite are those that it is hardest to do so.
A lot of the time it is also preferable to rewrite in the same language as the original, i.e. rewrite a badly written C++ app in C++ rather than moving to Java or C# because they are "cool". With regards to VB I don't know how well VB mixes with C# on .NET, assuming that is now the way to go but being able to rewrite a bit of your application whilst maintaining the rest for now is better than rewriting the whole thing.
There is for me usually a 7-stage phase to a rewrite, i.e.
Assuming the tests all still pass the job should be done.
And the great thing is that there is a very simple rollback step in the case of a bug, you just roll back step 7. As long as the external code is not using your implementation you have more time to test and fix it. The old code is still there but can be removed at a much much later stage.
Admin
Ya, screw blaming the root cause, there's a software company we can lynch!!!!
Admin
Ya, screw blaming the root cause, there's a software company we can lynch!!!!
Admin
Admin
Cool! A weights-and-balances application for a DHC Dash 8 - written in VB6...with, um, "minimal" error handling...and questionable numbers?
Just one question - which airline uses this thing...and how do I manage to NOT fly with them..?
Ol' "...can you say 'center of gravity'? - I knew you could..." Bob
Admin
The one and only feature I like about VBA is named parameters. Now that every language but C/++ has them, it's not so unique. (Yes, I know Pascal had them before.)
Admin
I think "pax" is standard airline lingo for passengers. It's not unreasonable to figure that the person doing the programming knows the field and uses the standard lingo of what they are writing about.
Admin
Why not an else if on that second test? The conditions are exclusive, and the testers will thank you for removing an impossible path if they have to meet a path coverage metric. Or at least not curse you for leaving it in.
Admin
More distressing I find the assumption, that nearly each boolean expression found in the above function is the direct result of an before made error with painful consequences.
Admin
Or CICS. <shudders>
Admin
Admin
So this is cargo cult programming...
Admin
You want to change the default names because the code is still code, and no matter what visual framework you have to tie it together it still needs to be readable standing on its own.
Sure, when you approach the Command696_Clock method by navigating the UI to the button and asking the environment to show you the code behind it, you know by context what Command696 is - "why, it's the submit button for this form that I just navigated to".
But when that code refers to Frame123, Radio592, and Form37.Command42, suddenly things don't look so great for your poor maintenance programmer. Yes, he can probably navigate the UI to find those things; and indeed there are some features of the environment that will help him do so. But there is no reason he should have to do so.
There is no such thing as "visual programming" as an alternative to procedural programming. "Visual" describes the development environment; "procedural" describes the code. (Actually I think MS uses some half-baked term like "object based" as a concession to the fact that although they want to call it OO, it really isn't.)
Actually, that's moot anyway; what makes you think proper naming would be peculiar to procedural programming?
Admin
Not sure what the prob is here, other than the empty ELSEs. Assuming that all those checks have to be made, then they have to be made. I don't see anything redundant or unnecessary (albeit, I only gave it a quick scan.)
Admin
"On that note, VB has a bad wrap less becuase of the language, and more because of its accesibility."
As a scientist, I had to maintain code written in Labview and I can tell you it's even worse. National Instrument has spent years advertising that Labview does not require any programming skill. Combine that with the impossibility to add meaningful comments to Labview code and you have the best recipe for success.
Admin
This code is a beautiful thing.
-when compared to SSDS.
Admin
You sir are an arrogant ass. I suppose your code is perfect. Right. It isn't. Jerkoff
Admin
TRWTF is that you're reimplementing by hand, something that looks code generated.