- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Indeed. This may be the Rube Goldberg of percent calculations.
Admin
Oh wait, it could be.
But probably not by this guy....
Admin
Is it weird that I feel the need for caffiene after reading that small bit of code?
Schizer if that is the good part I am slightly morbidly fasinated on what the rest of the code looks like.
Admin
Seriously, can I take him into the middle of a paddock and shoot him?
Admin
There is hardly [any program] in the world that some man [with lesser skill] cannot make a little worse and [be paid a little less], and the [management that] considers price only [deserves what it gets].
Admin
Admin
Admin
Admin
Admin
Heisenberg computing! The act of watching the battery life changes it.
Admin
This is actually very clever, because it ensures that if the returned value is unexpected (-1 for example), you don't get a strange readout, but instead get a simple "NA".
Think of all the Error'd we get here with -99999 temperatures etc. This code is invulnerable to such defects.
Admin
Why did you only change five cases?
Admin
If you CAN teach programming, I encourage anyone to do a little. It gives you the opportunity to give some wisdom to others... and you learn some fairly interesting things. The last classes I taught had an influx of quite a few young men who thought computer programming just had to be dead-easy and so they signed up for programming classes. Why did they reach this conclusion? Because they saw the same commercial I saw for some programming school that featured a couple college guys on a couch playing video games basically saying "computer programming is easy!" They were literally convincing students to come take programming classes (at their school with government grant money, of course) because it was the same as playing video games. I was aghast at the commercial. Speechless when several students affected by the ads showed up in my classes.
Admin
As I recall, they did a survey of operations and found that assignment was used at least twice as often as comparisons for equality, so they opted for shorter symbology for assignment.
Admin
As good an excuse as any, I suppose. Just like Y2K, "saving bytes" has caused us more pain than all other programming WTF's combined.
Admin
Admin
You realise it's 2012...? I honestly hope you're not referring to VB6.
O bother that's worse than those who were being paid for COBOL programming for Y2K fixes...
Admin
I worked with people who would read this information from an Oracle table.
An INDEXED Oracle table!
Brainy hurty much.
Admin
Admin
If you had a licensing board, then you'd have to know PL/I, COBOL and FORTRAN IV. Your license would also only be good in the state it was issued in. To get it would require 2000 hours of program design, vs just coding while working for licensed programmer.
Admin
If any coder that I ever work on a project with ever checks code like this into the project repository, I'm going to calmly walk over to his cubicle and put a bullet through his head.
Whoever did this does not deserve to live.
Admin
It would also avoid querying the system for battery state 100 times...
Admin
Also remember that anyone that stupid can be failed and kicked out. While yes, the school might not be too happy at losing the income, they'll support getting rid of idiots as they're all to likely to cause problems in lots of other classes too. Why have a moron when you can have three ordinary students for the same teaching effort?
Admin
[quote user="PedanticCurmudgeon"][quote user="slamers"]If the licensing board were full of bad programmers, we might have our licenses suspended for using design patterns.[/quote]
...because nobody is using them, anywayz.
That would redefine the term good/bad programmer (developer?)
Admin
Right now I am maintaing a VB6 application for supermarkets. Sadly enough, it is well written. However I can say: TRWTF is in the database (which is SQLServer, hence MS, hence...)
captcha: caecus, is this a new form of feces?
Admin
and he wouldn't have called the same function 99 times (in the worst case)
Admin
Just because you insisted: you are using the LINQ library but I can't see why.
Admin
Pretty sure a bunch of failed 'if' statements will consume more power than "Math.Trunc(battery life * 100)" or "(int)(battery life * 100)".
Admin
Because that's automatically generated by the IDE, and not worth the time to remove.
I am surprised through that you only noticed the System.Linq as being extraneous while both System.Text and System.Collections.Generic are equally unused.
Admin
Admin
I worked in a team where the boss was very proud that he had a team member who was an "accredited programmer", having gone through some officially-recognised (and probably expensive) series of training courses. His colleagues were less impressed with this guy's credentials, as his code was severely substandard. He knew the techniques (as they had been taught) but was a dunce at applying any form of analytical thinking to the tasks he was assigned.
Example: he implemented a generic comparator method (so as to be able to sort a table of variegated java objects) as a series of bubble-sorts surrounded by if-thens of almost as high a quality as today's exemplar. The only difference between those bubble-sorts was the objects on which they were operating. And what made this particular class even more worthy of ridicule, he had cited the name and serial number of the course in which said bubble-sort had been taught. The trouble is, we had no incentive to replace it with something more sensible because it worked and we had no need at that time to expand it.
Admin
Is anybody willing to produce some metrics?
Admin
Admin
Admin
This is brilliant. Everybody knows your battery is like almost full and then studdenly drops half way your call to empty. This table mitigates for that. I can give different percentages depending on what value you get. I should have thought of it!
Admin
Admin
and that's why
a = b = c
is perfectly valid syntax. Only the stupid doesn't understand this line of code.
Admin
Writing "if (a = b){" on other languages bit me one too many times.
Admin
Admin
"clear from context which is meant."
flag = value = 7
Multiple assignment or logical expression ? I suppose if one knows that flag is a boolean, but only in strongly typed languages.
Admin
The correct way is SystemInformation.PowerStatus.BatteryLifePercent.ToString("0%")
That's it. Changes a double to a whole-number percentage string.
Admin
Admin
Admin
-1000 for not seeing the Animal House reference.
Admin
Admin
Admin
Working with Objective C, you need to make sure objects haven't been deallocated:
SystemInformation.PowerStatus.BatteryLifePercent.ToString != nil Then Return "100%" ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" && SystemInformation.PowerStatus.BatteryLifePercent.ToString != nil Then Return "99%" ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" && SystemInformation.PowerStatus.BatteryLifePercent.ToString != nil Then Return "98%" ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" && SystemInformation.PowerStatus.BatteryLifePercent.ToString != nil Then Return "97%" ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.96" && SystemInformation.PowerStatus.BatteryLifePercent.ToString != nil Then Return "96%" ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.95" && SystemInformation.PowerStatus.BatteryLifePercent.ToString != nil Then Return "95%" ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.94" && SystemInformation.PowerStatus.BatteryLifePercent.ToString != nil Then Return "94%" ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.93" && SystemInformation.PowerStatus.BatteryLifePercent.ToString != nil Then Return "93%" ...
Admin
Oh, I get it now!! The code isn't enterprisey enough. It's not re-usable because he not only hard-codes the BatteryLifePercent function, but he also embeds the "%" in the return value, thus making it inapplicable to other cases. What he should have written was this:
Admin
C'mon.. I want to know what was snipped!
Admin
You guys laugh, roll eyes or wonder how someone could code like this. Sadly I've seen this style of copy-paste coding from quite alot of people taught in Indian universities. I'm not simply stereotyping, this is a phenomena observed by other colleagues too. It really is incredible how bad the level of instruction they receive over there. Surely it's gotten better but I wouldn't hold my breath...