Appalling Coding Technique
-
I've just been trying to debug some old C code and I stumbled across this little beauty
if ( CANT ValidateIncomingGoods(pMsg))
{
...I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find
#define CANT !
Time for random acts of violence around the office. Cheers James
The virtues of Hungarian notation :laugh: Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
-
Where do you guys find these people? :eek:
I knew it would end badly when I first met Chris in a Canberra alleyway and he said 'try some - it won't hurt you'..... - Christian Graus on Code Project outages A moment of silence please. A programmer's best friend has passed beyond that great exception in the sky.... - Mark Conger on "The coffee machine has died"
Megan Forbes wrote: Where do you guys find these people? Coders 'R' Us. Either that, or they get them free in their breakfast cereal! You've got to be careful about criticising though... I once bashed a particularly onerous piece of cryptic spaghetti code I was assigned to port to a new system. My boss was less than sympathetic, as (unknown to me) he had written it 10 years before.:-O "My child was Inmate of the Month at Mohave County Jail" - Bumper Sticker in Bullhead City, AZ
-
I've just been trying to debug some old C code and I stumbled across this little beauty
if ( CANT ValidateIncomingGoods(pMsg))
{
...I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find
#define CANT !
Time for random acts of violence around the office. Cheers James
Many years ago I remember programming in PL/M (I think that was the language) with a construct like:
REPEAT
...
UNTIL the$cows$come$homewith the equivalent (I can't remember the language) of:
#define the$cows$come$home 0
It semmed amusing at the time...
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
-
Oh :omg: I have seen that one too in an old code I was expected to maintain : IFP(ValidateIncomingGoods(pMsg)) So i started wondering what could have been the magical things behind IFP. I was thinking about run-time object validation, and stuff like that. It fell short, #define IFP if :omg: :omg: :omg:
.S.Rod. wrote: It fell short, #define IFP if Yikes :eek: , there are some strange guys in the force ... Cheers,Joao Vaz And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary.-Shog9 Remember just because a good thing comes to an end, doesn't mean that the next one can't be better.-Chris Meech
-
I've just been trying to debug some old C code and I stumbled across this little beauty
if ( CANT ValidateIncomingGoods(pMsg))
{
...I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find
#define CANT !
Time for random acts of violence around the office. Cheers James
Here's some nice indenting that a co-worker of mine practices.
if(something) { while(somethingElse) { // some crap code here // some more crap here } }
Jason Gerard "This almost never matters, except quite often." -
Here's some nice indenting that a co-worker of mine practices.
if(something) { while(somethingElse) { // some crap code here // some more crap here } }
Jason Gerard "This almost never matters, except quite often."Sometimes unfortunately produced by source code diff mergers such as Clearcase and Araxis.
-
I've just been trying to debug some old C code and I stumbled across this little beauty
if ( CANT ValidateIncomingGoods(pMsg))
{
...I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find
#define CANT !
Time for random acts of violence around the office. Cheers James
James Spibey wrote: Time for random acts of violence around the office. Ah...A new sig :-D cheers, Chris Maunder Time for random acts of violence around the office - James Spibey
-
I've just been trying to debug some old C code and I stumbled across this little beauty
if ( CANT ValidateIncomingGoods(pMsg))
{
...I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find
#define CANT !
Time for random acts of violence around the office. Cheers James
Aaaaaaaaaaaaaa I came across something similar.. Someone around here had redefined the following
EQUALTO
ASSIGNTO
GTRTHN (greater than)
LESTHN (less than)
GTRLES (greater than or less than)
.
.
.You get the idea... Made for some interesting (and suprisingly readable) code, but drove some younger coders NUTS! Paul Watson wrote: At the end of the day it is what you produce that counts, not how many doctorates you have on the wall.
-
Aaaaaaaaaaaaaa I came across something similar.. Someone around here had redefined the following
EQUALTO
ASSIGNTO
GTRTHN (greater than)
LESTHN (less than)
GTRLES (greater than or less than)
.
.
.You get the idea... Made for some interesting (and suprisingly readable) code, but drove some younger coders NUTS! Paul Watson wrote: At the end of the day it is what you produce that counts, not how many doctorates you have on the wall.
Perhaps an ex COBOL programmer? Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
-
James Spibey wrote: Time for random acts of violence around the office. Ah...A new sig :-D cheers, Chris Maunder Time for random acts of violence around the office - James Spibey
Chris Maunder wrote: Ah...A new sig Imortalised at last. My work here is done :) Cheers James
-
I've just been trying to debug some old C code and I stumbled across this little beauty
if ( CANT ValidateIncomingGoods(pMsg))
{
...I'm thinking, 'WTF is this CANT thing?' So I grep around a little and at the top of the file I find
#define CANT !
Time for random acts of violence around the office. Cheers James
-
Megan Forbes wrote: Where do you guys find these people? Coders 'R' Us. Either that, or they get them free in their breakfast cereal! You've got to be careful about criticising though... I once bashed a particularly onerous piece of cryptic spaghetti code I was assigned to port to a new system. My boss was less than sympathetic, as (unknown to me) he had written it 10 years before.:-O "My child was Inmate of the Month at Mohave County Jail" - Bumper Sticker in Bullhead City, AZ
Roger Wright wrote: My boss was less than sympathetic, as (unknown to me) he had written it 10 years before. Been there before. I'm....more vocal than I should be when it comes to other people's code that doesn't work properly. So when I told our team's architect "Someone did a buck-up job here".... well... it wasn't pretty. :-O That's why I ramble so much. If you're short and quotable, there's a much greater danger of ending up in a sig. [Christopher Duncan on how to prevent yourself from ending up in a sig]
-
Well, you have to give the guy some credit for trying to make the code more readable. Did you know that the C++ Standard Library has these defines:
#define and &&
#define and_eq &=
#define bitand &
#define bitor |
#define compl ~
#define not !
#define not_eq !=
#define or ||
#define or_eq |=
#define xor ^
#define xor_eq ^=I don't use them myself (I'm used to the cryptic syntax) but doing so can definitely improve readability. Regards, Alvaro
Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)
You friend is only following the ISO 646 rules. You can also do the following on Visual C++
#include
My latest article: SQL Server DO's and DONT's[^]
-
Perhaps an ex COBOL programmer? Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
This code was in a project written for an OS/2 based Unified messaging system that used modules written in: COBOL C Pascal Rexx So this was entirely possible... never gave that much of a thought before... The code was still hell to read... and the GUI!... UGH! Looked like it was designed by a company that made tile mosaics... No allignment of GUI elements, no text boxes the same size, on the same form... what a mess... and to top it all off, it was supposed to connect to a Lotus Notes server! No wonder it died.... Paul Watson wrote: At the end of the day it is what you produce that counts, not how many doctorates you have on the wall.
-
Sometimes unfortunately produced by source code diff mergers such as Clearcase and Araxis.
Seeing as how we don't use these and I've stood over his shoulder before as he coded, I know this is not the case. Jason Gerard "This almost never matters, except quite often."
-
Oh :omg: I have seen that one too in an old code I was expected to maintain : IFP(ValidateIncomingGoods(pMsg)) So i started wondering what could have been the magical things behind IFP. I was thinking about run-time object validation, and stuff like that. It fell short, #define IFP if :omg: :omg: :omg:
.S.Rod. wrote: #define IFP if Did you find #define if ifp too? because he really should be shot then.
We brought out this new and very similar version of our expensive software because the old version was......old....It's a good enough excuse for Microsoft so its fine for us.
-
Seeing as how we don't use these and I've stood over his shoulder before as he coded, I know this is not the case. Jason Gerard "This almost never matters, except quite often."
So I guess my effort to save him is useless. ;P