|
I feel you pain. Old habits do die hard, so the trick is learning the right habbits. Asking yourself "Do we have a backup?" is the best habbit to have. Beyond that is a functional understanding of what the compiler is doing to your source, regardless of the language. Unfortunately too many people try to compare a medium-level language like C or C++ to a high level language like C# based on the syntactical similarities alone.
|
|
|
|
|
Actually, this code has a somewhat subtle behavior, since it is catching by-value, prior to throwing.
If a derived exception is thrown, it will be "clipped" to the base class when it is thrown. This could be potentially
different from invoking throw, which would throw the derived class.
|
|
|
|
|
One of my favorite incidents happened over 10 years ago when computers were much less powerful. An engineer came to me with a financial forecast spread sheet that was taking 4-6 hours to run. After speaking with him about what he was attempting to accomplish, I rewrote his application in FORTRAN (the engineering language of choice at that time) and he was able to do an analysis in 6 seconds! That is not a misprint.
This engineer was intimately familiar with spread sheets, his only tool was a hammer, so everything looked like a nail.
Brian Leach
|
|
|
|
|
Brian Leach wrote: This engineer was intimately familiar with spread sheets,
won't touch it. nope. not gonna.
|
|
|
|
|
I'm going through the same thing now, inherited a bunch of Excel "reports" to maintain. Oh, the horror!
-- modified at 20:29 Monday 5th March, 2007
Oh, and... every tool is a hammer.
|
|
|
|
|
VBA/Excel03 still has the same performance penalties over modern languages. >30min to ~1s (timed from button click to completed dialog appeared, so a decent chunk of that second was form loading)
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
In the last company I worked (about 8 years back), I was asked to fix a bug in some invoice processing module. The main code was in a single function which had about 30,000 (hyperbole, don't remember the xact no but it was enormous) lines which is a WTF in itself. It was a common practice in the whole application. When looking at the issue to solve, I also found that there was a major issue that caused the code database to rollback even when the processing was successful. Believe it or not the issue was that braces did not match properly in that 30000 lines of code. I wish I kept the original code but after struggling for about a day I finally re factored the code and separated into various functions and made it work.
It did not here. Some people working at a client's place found the issue of Rollback and notified the team leader. The team leader compared the code and thought that it was my changes that lead to this issue. I debated with him for lot of time but apparently he did not like the idea of clean code. He (who also happened to like me) had worked with the app for about 5 years and was probably not used to the clean code. Finally, the QA tests revealed that my code was the one which was working properly. However, I still had to remove all the refactorings I did to my code (mostly function extractions) and put back in that one large function.
Needless to say that I left the company in another 2 months.
|
|
|
|
|
Yup. That is one issue that sneaks up on all of us. In the past I've had to "make only those modifications that will fix the described issue" for what were called patch builds. And as you can guess, when the customer received and used the "fixed" code, it broke just as badly as before. That company is now struggling to survive.
Phil
|
|
|
|
|
Wow - that's amazing. I've seen some terribly long functions ( which I then refactor, obviously ), but nothing that bad. What a nightmare.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I can fully understand your reasons for leaving. Makes you thing that no one has ever heard of structured coding.
The worst I have seen was while extending a DLL written in C. Apparently the orignial developer did not understand how to pass parameters, instead using about 2000 global variables.
Fortunately I was able to put my foot down and get rid of all but one or two globals.
|
|
|
|
|
For the last few months, i've been enhancing and maintaining a library written in VB.NET.
I've done a lot of other stupid, miserable things during this time, but this library pretty much takes the cake in terms of filling me with shame and self-loathing at the end of a long day. It's somewhat akin to knowingly feasting on mudpies, all day, for weeks at a time...
----
It appears that everybody is under the impression that I approve of the documentation. You probably also blame Ken Burns for supporting slavery.
--Raymond Chen on MSDN
|
|
|
|
|
Shog9 wrote: For the last few months, i've been enhancing and maintaining a library written in VB.NET.
I've done a lot of other stupid, miserable things during this time, but this library pretty much takes the cake in terms of filling me with shame and self-loathing at the end of a long day.
So why didn't you just rewrite the thing?
|
|
|
|
|
The Grand Negus wrote: So why didn't you just rewrite the thing?
Well, i am, a bit at a time. But technically, i'm not supposed to be spending all that much time on it - the original plan was, i'd take over ownership of it, but any work would be done by outside consultants, thereby freeing me up to work on more interesting projects. So... now i'm slowly learning to program consultants. In the meantime, there's still work that needs to be done...
----
It appears that everybody is under the impression that I approve of the documentation. You probably also blame Ken Burns for supporting slavery.
--Raymond Chen on MSDN
|
|
|
|
|
Shog9 wrote: So... now i'm slowly learning to program consultants.
Big job. What language are you using for that?
|
|
|
|
|
Since i don't know Hindi, i'm trying to use English. It's not a very good fit.
----
It appears that everybody is under the impression that I approve of the documentation. You probably also blame Ken Burns for supporting slavery.
--Raymond Chen on MSDN
|
|
|
|
|
Is there any reason you can't convert it to C# ? Excellent tools exist for this purpose.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Other than the one you illustrated below?
It's not the syntax that really irritates me; it's the little programming techniques that, by now, just scream "VB" to me: insufficient error handling, massive amounts of duplicate code, unnecessary use of late binding, etc. Every time i need to make significant changes to a class or routine, i'll re-write it, to where it reads the same as it would have if i'd written it in C#. Eventually, i'll either have re-written the whole thing to where converting it to C# will be painless... or i'll have pushed the project off onto some other poor sucker, and won't care anymore...
----
It appears that everybody is under the impression that I approve of the documentation. You probably also blame Ken Burns for supporting slavery.
--Raymond Chen on MSDN
|
|
|
|
|
You do have "Option Strict" on?
|
|
|
|
|
It's set up to warn. Eventually, i'll manage to clear up all the warnings...
----
It appears that everybody is under the impression that I approve of the documentation. You probably also blame Ken Burns for supporting slavery.
--Raymond Chen on MSDN
|
|
|
|
|
In my experience, the language used and the options set to the strictest of standards still doesn't prevent people from writing bad code.
Phil
|
|
|
|
|
I agree. It sounds like the original code was written in .NET "VB6 procedural" style, and not leveraging any of the benefits provided to VB developers through .NET. It's an unfortunate side effect of people not upskilling their techniques with the move from VB6 to VB.NET.
|
|
|
|
|
Haha. I hate to say this, but in my career, I keep coming across projects that are mostly C# with a small percentage of awful VB.Net code. (I do find GOOD VB.Net code on the 'net.)
For example, in my first job out of college, 95% of the code was in C#. There was one group of dlls written in VB.Net where the developer had all methods take a single array of objects as THE argument. Even weirder was that almost all of the values being passed on the stack belonged as object-level fields. The code was an example of how NOT to use weak typing.
It was very clear to me that the original developer spent a few months on the code... I re-wrote it all (from scratch) in 3 days!
|
|
|
|
|
I work on an app that was started by someone else in VB.NET. I hope it was the conversion to C# that causes me to still find code like:
for(int i = 0; i <= myObject.Length - 1; ++ i)
or, even better:
int g = item.Count - 1 + 1;
I find examples of both of these almost every time I wander into the guts of stuff I've not had to touch before, like some of the basic controls we suddenly decide to change after 2 years.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
?That sounds like the kind of moment where you wish the ESC button worked.
Brad
Australian
- Christian Graus on "Best books for VBscript"
A big thick one, so you can whack yourself on the head with it.
|
|
|
|
|
*grin* yeah, I certainly did a double take.
Converting to C# took a half day to make work, and 2 days more to make work once I removed all references to the Microsoft.VisualBasic namespace. It was well worth it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|