What a gem.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
And well commented. I think we can all appreciate the thoroughness of the approach.
_____________________________ Give a man a mug, he drinks for a day. Teach a man to mug... The difference between an ostrich and the average voter is where they stick their heads.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
And found another similar bit of work (done in Perl, so may be 'leigt'?) http://pastebin.com/TiyDDuPp[^]
for ($loopCount=0; $loopCount <= $stringLength; $loopCount++) {
$char = substr($inputString,$loopCount,1); if ($char eq 'a') { $char = uc($char); } elsif ($char eq 'b') { $char = uc($char); } ... elsif ($char eq 'z') { $char = uc($char); } else { $char = $char ; } $outputString = $outputString . $char; }
return $outputString;
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
It couldn't have been done with a generic approach, look at the last line:
Else
Return "NA"That required a custom solution! Just kidding ;) BTW, shouldn't that be 'N/A'?
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
-
It couldn't have been done with a generic approach, look at the last line:
Else
Return "NA"That required a custom solution! Just kidding ;) BTW, shouldn't that be 'N/A'?
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
Julien Villers wrote:
BTW, shouldn't that be 'N/A'?
Na
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
Wow! This is only not worse than what I've seen, because the DB field length related to what I found is small:
public string GetStringToDatabase(int value)
{
if (value > 99999999)
return "0" + value.ToString();
else if (value > 9999999)
return "00" + value.ToString();
else if (value > 999999)
return "000" + value.ToString();
.
.
.
}"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
Maybe they got paid by the line
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
-
It couldn't have been done with a generic approach, look at the last line:
Else
Return "NA"That required a custom solution! Just kidding ;) BTW, shouldn't that be 'N/A'?
'As programmers go, I'm fairly social. Which still means I'm a borderline sociopath by normal standards.' Jeff Atwood 'I'm French! Why do you think I've got this outrrrrageous accent?' Monty Python and the Holy Grail
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
What a shortcut! A qualified programmer would have accounted for the fact that BatteryLifePercent is floating point, and may not be in increments of 1/100th. What if it's 0.975? Obviously this should have been written as:
If SystemInformation.PowerStatus.BatteryLifePercent <= 1 And
SystemInformation.PowerStatus.BatteryLifePercent > 0.99 then Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent <= 0.99 And
SystemInformation.PowerStatus.BatteryLifePercent > 0.98 then Return "98%"
...:)
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
They are clearly just coding around a bad framework. There's a field called BatteryLifePercent, but it's not actually a percentage number. Obviously the framework is incorrect.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
Option Strict is off or the Property would have an As clause! Correct would've been:
Public ReadOnly Property BatteryPercent As Percent
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
' No implicit conversions with Strict On!
Return Convert.ToPercentage("100%")
' Etc...Now that just made a world of difference :)
It's an OO world.
public class Naerling : Lazy<Person>{
public void DoWork(){ throw new NotImplementedException(); }
} -
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
Could be wrong but it looks like a case of lack of knowledge, not knwoing/understanding that there is a better/more effecoent way to achieve teh same goal. I work in RDBMS (sepcifcally SQL Server) and I routinely see this same kind of bad design choice and usually its due to a lack of knowledge/eductaion on the product/system. For example when the develoepr needs to store a bolean value ( 0 and <>0 ) they use a NUMERIC data type which [by default) uses 9 bytes instead of using the smaller BIT data type.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.
This is why degrees are useful. You may not be the best programmer in the world after graduating, but at least you should learn enough to avoid code like this. Having a get-r-done attitude is fine and all, but a get-r-done intelligently attitude is much better.
Somebody in an online forum wrote:
INTJs never really joke. They make a point. The joke is just a gift wrapper.
-
Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:
Public ReadOnly Property BatteryPercent()
' This code will retrieve the BatteryLifePercent property and convert it to a percent.
Get
If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
Return "100%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
Return "99%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
Return "98%"
ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
Return "97%"
... etcWow is all I can say.