I support a software system that has been in place for going on fifteen years. There are large parts I have never touched. There are large parts I have never seen. When things work you leave them alone. I’m working in a piece I rarely enter and I have just seen some grotesque lines of code. Here’s an example:
send[0]=send[1]=send[2]='+';
There’s not really that much wrong with this example, but it’s indicative of the style of the guy who wrote it. He uses “shortcuts” when he doesn’t need to (a strcpy or a constant wouldv’e been fine here, IMO) and he rarely used functions. Lots of inline code here people. Makes for fun reading.
Have you seen the dreck MS is encouraging with .NET? Some people never got the hang of cout <<…, but then the codier-than-thou from Redmond have now dictated that you use a System::Console::Writeln(…). So much for code portability. Feh.
“shit” barely describes this stuff. I’m trying to develop a network application for aircraft telemetry, and part of the deal is that I don’t know what the platforms will be, UNIX/Sun, PC/Linux, or PC Win2K. Therefore it has to be developed as generic as possible.
I’m provided with a copy of the newest Visual Studio .NET, and I barely recognize any of the example socket programs as anything like C or C++. MS has done an excellent job sticking a knife into the concept of stream IO, and tied all the BSD socket classes to the new bastardized IO facilities so whatever you learned in school is useless.
DaddyTimesTwo My sympathies. I get to support a C program now past its 14th birthday, still live in use at dozens if not hundreds of sites. It does use functions but some of them are big I just checked one that’s 671 lines long. It depends on a whole bunch of global variables and arrays all altered by function side-effects, here’s a taste of some of the logic:
it’s not hard code but its pretty hard on the eye. BTW what was the guy thinking in your example:
send[0]=send[1]=send[2]='+';
I presume you sort of get the string “+++” but it’s not terminated, it’s dangerous, it’s not even clever code so why do it? Do you have any more examples we can go huh? at?
vunderbob Whatever you learned in school, if it’s not useless now it will be in two years’ time. Unless you get to support legacy stuff like some of us. And - if you’ve got to support *nixs why aren’t you using Java? Coz as far as I know .Net sure won’t run on a Sun box. And no, I am not a Java fan.
I don’t use Java because I never learned it, and with my old school engineering sensibilities, I probably won’t try until it breaks into the embedded software arena in a big way. Not that it hasn’t been done, but the area is still the domain of C/C++/assembly programming.
** Small Clanger**, I would say the smaller functions in my app are around 671 line. Some of them easily top 1000 lines or more. Basically, they aren’t really functions. There’s lots of little text files that get opened, written to, and closed, all inline with no error checking. It’s not terribly difficult code, like you says, there’s no math or hard science involved like I imagine vunderbob is dealing with, it’s just impossible to get a handle on it cause there’s so much jammed in. And there’s tons of stuff that’s probably obsolete, but who has the time to deal with pruning old code? I’d probably just break something else and make a month’s work out of something that was supposed to save me some time.
Not that I’m complaining or anything. My job hasn’t been sent to India or China or Bulgaria yet.