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
It looks someone being funny. In old college times, we used to work Turbo C 2.0 on computers (a 286 was quite expensive that time, about $5000) which were shared with other courses, so they were always occupied. To speed up people freeing a computer, I added the following "feature" to stdio.h, on the best machine we got:
#define while(x) while(1)
Obviously, I used "touch" to reset the file date and time back to the original one. People blamed the computer "this machine is fast but is damaged" :-O My latest article: SQL Server DO's and DONT's[^]
-
It looks someone being funny. In old college times, we used to work Turbo C 2.0 on computers (a 286 was quite expensive that time, about $5000) which were shared with other courses, so they were always occupied. To speed up people freeing a computer, I added the following "feature" to stdio.h, on the best machine we got:
#define while(x) while(1)
Obviously, I used "touch" to reset the file date and time back to the original one. People blamed the computer "this machine is fast but is damaged" :-O My latest article: SQL Server DO's and DONT's[^]
Daniel Turini wrote: #define while(x) while(1) Priceless. :-D I didn't know you could use x to stand for anything in a define.
Simon Walton
Sonork: 10024P
-
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
I'm sorry .. but I actually liked that .. certainly makes it nice and readable.
-
Almost as great as
#define private public
:-D
Simon Walton
Sonork: 10024P
Actualy, I've had to resort to doing that exactly once to hack around the broken Microsoft STL headers... simply no other way to get it to work, other than using STLPort, which the PHB's refuses to use since it wasn't a "commerical" product
Visual Studio Favorites - improve your development! GUIgui - skin your apps without XP
-
I'm sorry .. but I actually liked that .. certainly makes it nice and readable.
-
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
At a company I used to work, there was a bunch of francophone linguist that were really good in their field of work, but didn't know much in programming, and since they had to work in the code to implement their things, someone ( before I worked there ) decided to redefine some of the keyword to be in french...
#define for pour
#define if si
#define else sinon
...so in some source files, there was a lot of french code mixed in! Max.
-
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
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.)
-
I'm sorry .. but I actually liked that .. certainly makes it nice and readable.
So... It was YOU who did it!!! Only one person in the world can like it :) My latest article: SQL Server DO's and DONT's[^]
-
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]