Nodalmighty Posted October 7, 2010 Share Posted October 7, 2010 These are the sort of programmers I have to deal with: /************************************************************************************************************** * DATA - for percentage control on the base game * **************************************************************************************************************/ enum PercentagePayouts { PERCENT_72, PERCENT_74, PERCENT_76, PERCENT_78, PERCENT_80, PERCENT_82, PERCENT_84, PERCENT_86, PERCENT_88, PERCENT_90, PERCENT_92, PERCENT_94, PERCENT_96, PERCENT_98, NUM_PERCENTAGE_PAYOUTS, }; GeSInt32 GetOffsetFromPercentage( void ) { GeSInt32 nPerc = (GeSInt32)GetCabInterface()->PercentagePayout(); //NOTE THE VALUES IN THIS TABLE ARE 2% HIGHER THAN THEY SHOULD BE! if( nPerc { return( PERCENT_72 ); } else if( nPerc { return( PERCENT_74 ); } else if( nPerc { return( PERCENT_76 ); } else if( nPerc { return( PERCENT_78 ); } else if( nPerc { return( PERCENT_80 ); } else if( nPerc { return( PERCENT_82 ); } else if( nPerc { return( PERCENT_84 ); } else if( nPerc { return( PERCENT_86 ); } else if( nPerc { return( PERCENT_88 ); } else if( nPerc { return( PERCENT_90 ); } else if( nPerc { return( PERCENT_92 ); } else if( nPerc { return( PERCENT_94 ); } else if( nPerc { return( PERCENT_96 ); } else { return( PERCENT_98 ); } }; I just replaced all that crap with: #define MIN_PAYOUT 72 // Get percentage payout from cab shell (72%-98% in steps of 2%) as Float (i.e 72.0f). Convert to relative index (0-13) GeSInt32 GetOffsetFromPercentage( void ) { return ( ( ((GeSInt32)GetCabInterface()->PercentagePayout()) - MIN_PAYOUT_72) >> 1); }; And I know he's on a lot more money than me Quote Link to comment Share on other sites More sharing options...
Guest ugp Posted October 7, 2010 Share Posted October 7, 2010 I deal with exactly the same type of muppet every day! Frustrating to say the least. Quote Link to comment Share on other sites More sharing options...
Gaz6002 Posted October 7, 2010 Share Posted October 7, 2010 Yeah, but I had chips and beans with mine. Quote Link to comment Share on other sites More sharing options...
AndrewOW Posted October 7, 2010 Share Posted October 7, 2010 Yes, you will die. Quote Link to comment Share on other sites More sharing options...
Matt H Posted October 7, 2010 Share Posted October 7, 2010 I can read the matrix in that. Quote Link to comment Share on other sites More sharing options...
kill1308 Posted October 7, 2010 Share Posted October 7, 2010 If he's on more money than you and doesn't really know how to program.... who would you class as the more intelligent one? Hehe, sucks though, but that sadly is the same with most companies, the real workers sit lower down and get shafted money wise. The further up the tree you go, the worse they are at their job usually. Quote Link to comment Share on other sites More sharing options...
shima60 Posted October 7, 2010 Share Posted October 7, 2010 If he's on more money than you and doesn't really know how to program.... who would you class as the more intelligent one? Hehe, sucks though, but that sadly is the same with most companies, the real workers sit lower down and get shafted money wise. The further up the tree you go, the worse they are at their job usually. Agree'd I had a guy at work that didnt understand the key enter.... I'v also asked people to go into "internet explorer" and type something in the address bar of which they come back and ask what the address bar is.. While i'm on with it the other day a woman said outlook had gone off her machine. It was literally the first thing in the start menu. just because it wasnt on her desktop she thought it had gone... Rant over *back on topic* Anyone in support knows that the people above them in the company are less likely to know what they are doing. Quote Link to comment Share on other sites More sharing options...
edinlexusV8 Posted October 7, 2010 Share Posted October 7, 2010 Quote Link to comment Share on other sites More sharing options...
Animal Posted October 7, 2010 Share Posted October 7, 2010 Maybe he's paid per character? Retard woman at work yesterday came out with the line "These batteries feel heavy - does that mean they're fully charged now?" The world is full of soft-skulled morons, luckily I can ignore most of them. Quote Link to comment Share on other sites More sharing options...
Nodalmighty Posted October 7, 2010 Author Share Posted October 7, 2010 This cnut has caused the company so much hassle with games failing of the target hardware, in front of clients and sexual harassment claims that got brushed under the carpet. I swear he must have pictures of the directors arse rapping each other or he is made of pure Teflon. Quote Link to comment Share on other sites More sharing options...
Charlotte Posted October 7, 2010 Share Posted October 7, 2010 Maybe he's paid per character? Retard woman at work yesterday came out with the line "These batteries feel heavy - does that mean they're fully charged now?" . What's wrong with that? Quote Link to comment Share on other sites More sharing options...
ozz Posted October 7, 2010 Share Posted October 7, 2010 Maybe he's paid per character? Retard woman at work yesterday came out with the line "These batteries feel heavy - does that mean they're fully charged now?" The world is full of soft-skulled morons, luckily I can ignore most of them. wow. My favourite IT call when I used to do proper work was someone called me cos their computer wouldn't boot. I went to the shopfloor saw the 3 bars on the screen saying no signal, looked at the cables dangling from the monitor going nowhere and just laughed at him. The PC had been removed the previous day by my IT colleague as it had a problem. I never did find out exactly how he was trying to switch it on... Quote Link to comment Share on other sites More sharing options...
Snooze Posted October 7, 2010 Share Posted October 7, 2010 Only points I'd have is that: a) your version operates differently in the case where PercentagePayout >= 98 or b) your version relies on an assumption about the underlying implementation of a non-typed enum (ie. ints starting at 0). Might make the code confusing to maintain for the next person to look at it (using a bitshift is extremely geeky, btw! ) Whilst I started out as a C programmer, loving concise code, I have grown to appreciate the impact of it and the benefits of a more easily understood, albeit more verbose coding style. Quote Link to comment Share on other sites More sharing options...
Thorin Posted October 7, 2010 Share Posted October 7, 2010 You can always spot a bad coder from massive if...else if...else if... statements Quote Link to comment Share on other sites More sharing options...
Guigsy Posted October 7, 2010 Share Posted October 7, 2010 i always found longer else if statements like that easier to follow. my dyslexic brain found them easier to follow. but then i was a sucky programmer Quote Link to comment Share on other sites More sharing options...
Lbm Posted October 7, 2010 Share Posted October 7, 2010 Due to a W7 DVD failure (it had massive scratch marks etc) I was told today by the nice professional lady who supplied the disc to format my DVD drive Quote Link to comment Share on other sites More sharing options...
GlennK Posted October 7, 2010 Share Posted October 7, 2010 IF (confused) RTFM Else LOOP Quote Link to comment Share on other sites More sharing options...
Attero Posted October 7, 2010 Share Posted October 7, 2010 I code in a language with a lack of a select case statement! Most requested feature ever. Quote Link to comment Share on other sites More sharing options...
jevansio Posted October 7, 2010 Share Posted October 7, 2010 Is your code supposed to do what his was doing, but more elegant? To me I can't see what either of you were trying to achieve? What's with the bit shift? Hell on 2nd visit his actually looks more sense than yours? I can see he is basically turning a percent payout into an enum. Take a value of 5 (PercentagePayout) his would return 0, yours is doing what (5 - 72) >> 1? I totally don't get what you are trying to achieve with that, bit shifting a negative number? Quote Link to comment Share on other sites More sharing options...
Abz Posted October 7, 2010 Share Posted October 7, 2010 I think you missed a couple of comma's! I don't know how you programmers do it, while I was in Deloitte we use to have a number of programmers sitting near us. They used to be in all day & night almost, I am sure I have never see some of them leave the building. They use to wear slippers in the office as well Quote Link to comment Share on other sites More sharing options...
Snooze Posted October 7, 2010 Share Posted October 7, 2010 Is your code supposed to do what his was doing, but more elegant? To me I can't see what either of you were trying to achieve? What's with the bit shift? Hell on 2nd visit his actually looks more sense than yours? I can see he is basically turning a percent payout into an enum. Take a value of 5 (PercentagePayout) his would return 0, yours is doing what (5 - 72) >> 1? I totally don't get what you are trying to achieve with that, bit shifting a negative number? The code looks like it's trying to turn an int (the percentage payout - I'm guessing intended to be between 72 and 98) into an enum. Becuase the enum is non-typed, the underlying implementation actually generates ints starting at 0 to represent the enumeration. The rewrite is taking advantage of this fact by implementing the conversion as a mathematical algorithm: (PercentagePoint - 72) divided by two, rounded down. (use of the bitshift is a fast way of doing divide by two, round down). To me - the bitwise shift is non-obvious, the ab(use) of the fact that the enum is actually an int is risky, and the edge/error cases (PercentagePoint98) are now handled differently, but the new implementation will be a lot quicker. It's a decision for absolute performance vs. defensive coding and maintainability, IMO Quote Link to comment Share on other sites More sharing options...
Robzki Posted October 7, 2010 Share Posted October 7, 2010 Quote Link to comment Share on other sites More sharing options...
jevansio Posted October 7, 2010 Share Posted October 7, 2010 If we assume the input is between 72 & 98 yes it would work, but we can't assume that is the case. I know what a bit shift achives, and that is a terrible use of it, hell dviving by 2 and casting to an int would have been far more intiutive, what if they change the payout bands? It's a decision for absolute performance vs. defensive coding and maintainability, IMO Those are the sort of tricks you play in hardcore routines that are being executed millions of times a second, I can't see this "working out of a payout" being that type of call. IMHO defensive coding & maintainability win in this scenario for me, Quote Link to comment Share on other sites More sharing options...
Scott Posted October 7, 2010 Share Posted October 7, 2010 Due to a W7 DVD failure (it had massive scratch marks etc) I was told today by the nice professional lady who supplied the disc to format my DVD drive Mother-in-law had a problem with her PC when I started going with Charlene. Didn't want to overstep my mark as I didn't know them that well so I left her to the "help line". After a while and a lot of confusion I decided to step in and take over the phonecall. The girl on the other end of the line was offering to send out a recovery disc. I asked if she meant a windows installation, she said "nooooooo, the floppy diskette to recover windows". I remarked that it was used for a hidden partition which this particular PC didn't have. She said that it wasn't and that it had windows and all the other programs on it. I asked "on a 1.44mb floppy disk?" she said "yes". Hung up there and then, reformatted the PC with my "copy" and all was well till the motherboard blew up. Typical packardbell. Worst of it is she was on the phone for over an hour, and it was £1 per minute. Quote Link to comment Share on other sites More sharing options...
jevansio Posted October 7, 2010 Share Posted October 7, 2010 Then someone comes along and for some reason sets PERCENT_72 = 1 in the enum, or removes/changes the value of one, his code works, the new would go as an undected bug for ages Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.