Comment On Useless Functions, Extreme Naming, and More

"We had a programmer in our company whose specialty was to write functions that embodied his own personal traits," Winston Muller, writes "do absolutely nothing and mislead everyone to think that something was done." [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: Useless Functions, Extreme Naming, and More

2011-10-30 21:57 • by twitter (unregistered)
frist. hope the 12$ was worth it Alex!

CAPTCHA: nulla. if(obj == nulla) { return ""a;}

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:05 • by anon (unregistered)
365070 in reply to 365061
twitter:
frist. hope the 12$ was worth it Alex!

CAPTCHA: nulla. if(obj == nulla) { return ""a;}
You're not only first, you commented 11 hours before the article was posted! #ninja

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:06 • by Matt Westwood

writtenComment() {
return true;
}

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:10 • by The Mr. T Experience (unregistered)
TRWTF is listing "French" and "Gay" separately.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:27 • by BentFranklin
In the 8th one the camel case is wrong. It should be:

public override void ManagerElations()

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:28 • by Gay (unregistered)
365074 in reply to 365072
TRWTF is listing my name and your name separately.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:29 • by Nagesh
First time I see use of generic in code

Is this production redy code?

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:38 • by Alex (unregistered)
You know, I think the last one is used in the DB/IDE we use at work: one of the syntax error message reads "You are missing a '*', a '*', an expression or a '*'"

Glad to hear the original coder of that statement found a job elsewhere

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:52 • by Fishertroll (unregistered)
// 10/31/00 - removing voter registration duplicate verification
// ** this could be part of the reason that we
// ** have been represented so poorly lately

Re: Useless Functions, Extreme Naming, and More

2011-10-31 09:53 • by boog
private var languageLabels:ArrayCollection = new ArrayCollection(

"English",
"German",
"French",
"Zunesis"
);
FTFY

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:10 • by trtrwtf
The Article:
/// <summary>
/// Log the user off the system. The method returns true or false for success or failure
/// </summary>
public bool Logoff(string strUser)
{
return true;
}


At least the comment is correct.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:26 • by Deus (unregistered)
Hey! I speak Gay.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:28 • by evilspoons
Looks like someone took their CS course explaining "magic numbers are bad" literally instead of in spirit.

I can see it being very important to change everything that says it uses X number of parameters to actually use Y.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:35 • by Matt Westwood
365088 in reply to 365071
Matt Westwood:

writtenComment() {
return THIS.IS.HOW.TO.WRITE.A.comment();
}

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:40 • by airdrik (unregistered)
Obviously, the problem is with the abbreviated names in the hierarchy. They would be so much more readable if they were just spelled out:

String yyyyMMdd = "yyyyMMdd"
// get account information
m_bankID = ofx.BANKMESSAGESERVICE1.STATEMENTTRANSACTIONSRESULTSET.STATEMENTRESULTSET.BANKACCOUNTFROM.BANKID;
m_accountID = ofx.BANKMESSAGESERVICE1.STATEMENTTRANSACTIONSRESULTSET.STATEMENTRESULTSET.BANKACCOUNTFROM.ACCOUNTID;
m_accountType = ofx.BANKMESSAGESERVICE1.STATEMENTTRANSACTIONSRESULTSET.STATEMENTRESULTSET.BANKACCOUNTFROM.ACCOUNTTYPE.ToString(); // this is an enum; convert to string

// get start and end dates of statement
m_startDate = DateTime.ParseExact(ofx.BANKMESSAGESERVICE1.STATEMENTTRANSACTIONSRESULTSET.STATEMENTRESULTSET.BANKTRANSACTIONSLIST.DATESTART, yyyyMMdd, System.Globalization.CultureInfo.InvariantCulture);
m_endDate = DateTime.ParseExact(ofx.BANKMESSAGESERVICE1.STATEMENTTRANSACTIONSRESULTSET.STATEMENTRESULTSET.BANKTRANSACTIONSLIST.DATEEND, yyyyMMdd, System.Globalization.CultureInfo.InvariantCulture);

// get closing balance and date this refers to
m_closingBalance = moneyInPenceFromString(ofx.BANKMESSAGESERVICE1.STATEMENTTRANSACTIONSRESULTSET.STATEMENTRESULTSET.LEDGERBALANCE.BALANCEAMOUNT);
m_closingBalanceDate = DateTime.ParseExact(ofx.BANKMESSAGESERVICE1.STATEMENTTRANSACTIONSRESULTSET.STATEMENTRESULTSET.LEDGERBALANCE.DATEASOF, yyyyMMdd, System.Globalization.CultureInfo.InvariantCulture);

m_transactions = new System.Collections.Generic.List<OfxTransaction>();
foreach (SimpleOfx.OFXBANKMESSAGESERVICE1STATEMENTTRANSACTIONSRESULTSETSTATEMENTRESULTSETBANKTRANSACTIONSLISTSTATEMENTTRANSACTION transactionStatementNode in ofx.BANKMESSAGESERVICE1.STATEMENTTRANSACTIONSRESULTSET.STATEMENTRESULTSET.BANKTRANSACTIONSLIST.STATEMENTTRANSACTION)
{
m_transactions.add(new OfxTransaction(
moneyInPenceFromString(transactionStatementNode.TRANSACTIONAMOUNT),
DateTime.ParseExact(transactionStatementNode.DATEPOSTED, yyyyMMdd, System.Globalization.CultureInfo.InvariantCulture),
transactionStatementNode.NAME,
transactionStatementNode.TRANSACTIONTYPE.ToString(),
transactionStatementNode.MEMO)
);
}

There, so much more readable!

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:40 • by AerieC (unregistered)
SimpleOfx.OFXBANKMSGSRSV1STMTTRNRSSTMTRSBANKTRANLISTSTMTTRN


It seems to me that SimpleOfx is anything but simple, but I'll take a stab at this one:

OFX Bank message server 1 statement turn rss teenage mutant ninja turtle real super bank transaction list status teenage mutant ninja turtle transmission.

Do I win?

(Captcha: opto. This property makes my opto nerve hurt.)

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:45 • by airdrik (unregistered)
365091 in reply to 365090
AerieC:
SimpleOfx.OFXBANKMSGSRSV1STMTTRNRSSTMTRSBANKTRANLISTSTMTTRN


It seems to me that SimpleOfx is anything but simple, but I'll take a stab at this one:

OFX Bank message seriously version 1 statement turn rss teenage mutant turtle real super bank transaction list status teenage mutant turtle transmission.

Do I win?

(Captcha: opto. This property makes my opto nerve hurt.)

ftfy

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:46 • by Coyne
I've seen something similar to the last in a COBOL code section here:

IF SOME-VAR = ZERO OR
SOME-VAR = ZEROES

Clearly someone who didn't understand that, in COBOL, ZERO and ZEROES are just different ways of saying the same thing.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:53 • by Utterly Confused (unregistered)
>#define TASK_RATE_ONE_SECOND (TASK_RATE * 40)

What would this mean, the number of TASK_RATE tasks in one second? If so, yeah, this is 200 for a TASK_RATE of 5 ms BUT it should be computed as 1000/TASK_RATE ***CONFUSED***

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:54 • by Bronie (unregistered)
365094 in reply to 365061
This is exactly reason why I don't like foreach - var tends to lose context.

What it should look like:

foreach (SimpleOfx.OFXBANKMSGSRSV1STMTTRNRSSTMTRSBANKTRANLISTSTMTTRN ofxbankmsgsrsv1stmttrnrsstmtrsbanktranliststmttrn in ofx.BANKMSGSRSV1.STMTTRNRS.STMTRS.BANKTRANLIST.STMTTRN)

{
m_transactions.Add(new OfxTransaction(
moneyInPenceFromString(ofxbankmsgsrsv1stmttrnrsstmtrsbanktranliststmttrn.TRNAMT),
DateTime.ParseExact(ofxbankmsgsrsv1stmttrnrsstmtrsbanktranliststmttrn.DTPOSTED, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture),
ofxbankmsgsrsv1stmttrnrsstmtrsbanktranliststmttrn.NAME,

ofxbankmsgsrsv1stmttrnrsstmtrsbanktranliststmttrn.TRNTYPE.ToString(), ofxbankmsgsrsv1stmttrnrsstmtrsbanktranliststmttrn.MEMO)
);
}

Re: Useless Functions, Extreme Naming, and More

2011-10-31 10:58 • by C-Octothorpe
That last one is eerily similar to the code-base I inherited about a year ago, except replace all the "safe" if blocks with try/catch blocks...
public static int StringToInt32(string str)

{
try {
return int.parse(str);
}
catch { return 0; }
}
Ahh, now that's a beaute! Or the single return variant:
public static int StringToInt32(string str)

{
itn returnValue = "";

try {
returnValue = int.parse(str);
}
catch { }

return returnValue;
}
Now if this "pattern" doesn't scream "I don't give a shit about the quality of my code", then I don't know what does...

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:00 • by C-Octothorpe
365096 in reply to 365078
boog:
private var languageLabels:ArrayCollection = new ArrayCollection(

"English",
"German",
"French",
"Zunesis"
);
FTFY
Oh silly me. I thought that was a list of languages, not genders... My bad.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:03 • by milleniumbug (unregistered)
#define TASK_RATE (5) //Task rate in milliseconds

WTF? Comments in define!

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:06 • by Matt Westwood
365098 in reply to 365096
C-Octothorpe:
boog:
private var languageLabels:ArrayCollection = new ArrayCollection(

"English",
"German",
"French",
"Zunesis"
);
FTFY
Oh silly me. I thought that was a list of languages, not genders... My bad.


+1

In order of presentation: "Male", "Neuter", "Female", "Indeterminate"?

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:07 • by geocities
The GetStringValue example is not a WTF, but just the result of thinking about the same cases (reference could be NULL) multiple times.

I frequently get this when I code via automatic electroencephalography input and lose concentration for a while. Most cases are caught by the optimizer; but sometimes, garbage slips through. The optimizer removes it usually, but not always. I frequently get this when I code via automatic electroencephalography input and lose concentration for a while.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:09 • by Bronie (unregistered)
365100 in reply to 365098
Matt Westwood:


+1

In order of presentation: "Male", "Neuter", "Female", "Indeterminate"?


"Both".

Captcha: vulputate

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:09 • by Zune-Tran (unregistered)
365101 in reply to 365078
boog:
private var tongueLabias:ArrayCollection = new ArrayCollection(

"English",
"German",
"French",
"Zunesis"
);
FTFY
ZFTY

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:29 • by Matt Westwood
365104 in reply to 365100
Bronie:
Matt Westwood:


+1

In order of presentation: "Male", "Neuter", "Female", "Indeterminate"?


"Both".

Captcha: vulputate


You wish.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:31 • by catdog (unregistered)
The one from Ryan is not a WTF. The method may just return now, but could easily be a hook for something that needs to be done for the future. The try/catch is probably something they require as part of a process for all of their methods, and it's better to do it in advance than not do it, so later when someone makes the method do something, not only do they have to remember their task but they have to remember to add the try/catch when that's something they never have to do for an existing method. It's the same reason why coding standards saying to use curly braces on single line statements: because why make someone remember they have to do it later when you could just mitigate the risk and do it now.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:42 • by Matt Westwood
365107 in reply to 365105
catdog:
The one from Ryan is not a WTF. The method may just return now, but could easily be a hook for something that needs to be done for the future. The try/catch is probably something they require as part of a process for all of their methods, and it's better to do it in advance than not do it, so later when someone makes the method do something, not only do they have to remember their task but they have to remember to add the try/catch when that's something they never have to do for an existing method. It's the same reason why coding standards saying to use curly braces on single line statements: because why make someone remember they have to do it later when you could just mitigate the risk and do it now.


Interesting how fashions change. There's lots of bollocks being talked about single line curly braces at the moment. I think it looks shit, by the way.

Used to be that the Egyptian style, a.k.a the K&R style, was king. Now suddenly it's not.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:46 • by geoffrey (unregistered)
m_accountType = ofx.BANKMSGSRSV1.STMTTRNRS.STMTRS.BANKACCTFROM.ACCTTYPE.ToString()


The Only WTF is that they didn't leave the application in COBOL in the first place, but tried to convert it to C.

In COBOL you don't have to write out the full parentage of a nested field like that, or have to bother with the ToString(). You would just write:

move ACCTTYPE to M-ACCOUNT-TYPE

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:48 • by Steve The Cynic
365109 in reply to 365097
milleniumbug:
#define TASK_RATE (5) //Task rate in milliseconds

WTF? Comments in define!

Nothing wrong with comments in a #define.

However, in the real world, "rates" are measured in Hz, not seconds. It should be TASK_INTERVAL or TASK_PERIOD or something like that.

Well, assuming it really is in milliseconds, that is, and not work-units per unit of time.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:52 • by iToad (unregistered)
365110 in reply to 365108
geoffrey:
m_accountType = ofx.BANKMSGSRSV1.STMTTRNRS.STMTRS.BANKACCTFROM.ACCTTYPE.ToString()


The Only WTF is that they didn't leave the application in COBOL in the first place, but tried to convert it to C.

In COBOL you don't have to write out the full parentage of a nested field like that, or have to bother with the ToString(). You would just write:

move ACCTTYPE to M-ACCOUNT-TYPE



So it has come to this... COBOL has become a better alternative than Java or C. That's just sad.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 11:57 • by frits
365111 in reply to 365109
Steve The Cynic:
milleniumbug:
#define TASK_RATE (5) //Task rate in milliseconds

WTF? Comments in define!

Nothing wrong with comments in a #define.

However, in the real world, "rates" are measured in Hz, not seconds. It should be TASK_INTERVAL or TASK_PERIOD or something like that.

Well, assuming it really is in milliseconds, that is, and not work-units per unit of time.


const int NUM_MILLISECONDS = 20;
...
int wtf = TASK_RATE * NUM_MILLISECONDS;
cout << wtf << endl;


output: 5
???


Addendum (2011-10-31 12:03):
EDIT: My misconception, sorry. Steve is absolutely correct. At least I can leave pretty code to harrass those who like monochromatic comments. :P

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:00 • by trtrwtf
365112 in reply to 365107
Matt Westwood:

Interesting how fashions change. There's lots of bollocks being talked about single line curly braces at the moment. I think it looks shit, by the way.

Used to be that the Egyptian style, a.k.a the K&R style, was king. Now suddenly it's not.


Style is fashion - do what everyone on your project does, it'll be okay.
K&R is popular in books because vertical line space is expensive in print. On the screen, vertical line space is free, and if it's an issue it's an alarm bell: time to refactor.

I prefer the One True Brace Style (Allman style) because it lets me line up the braces by eye, and makes the blocks more obvious. But whatever, in this world there are certainly bigger things to get worked up about.
Single-line braces are a belt-and-suspenders thing, at best. If you're doing everything else right, they don't make a lot of difference, and they busy up your code. If you're doing everything else wrong, they're not likely to make a lot of difference, and they busy up your code. So don't bother, I say, just do everything else right.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:13 • by geoffrey (unregistered)
365113 in reply to 365112
trtrwtf:
Matt Westwood:

Interesting how fashions change. There's lots of bollocks being talked about single line curly braces at the moment. I think it looks shit, by the way.

Used to be that the Egyptian style, a.k.a the K&R style, was king. Now suddenly it's not.


Style is fashion - do what everyone on your project does, it'll be okay.
K&R is popular in books because vertical line space is expensive in print. On the screen, vertical line space is free, and if it's an issue it's an alarm bell: time to refactor.

I prefer the One True Brace Style (Allman style) because it lets me line up the braces by eye, and makes the blocks more obvious. But whatever, in this world there are certainly bigger things to get worked up about.
Single-line braces are a belt-and-suspenders thing, at best. If you're doing everything else right, they don't make a lot of difference, and they busy up your code. If you're doing everything else wrong, they're not likely to make a lot of difference, and they busy up your code. So don't bother, I say, just do everything else right.


Reminds me of a job I had 15 years ago. I was moved onto a long running project and found myself on the "team" of a real bunch of K&R apologists. Despite my best attempts to educate them as to the merits of single line quotes they forced me to use K&R. Joke was on them though, each day I would secretly convert pieces of the code from K&R to single brace (as well as making some other more aesthetic and functional changes/improvements). Then when they went home each night I would disable the source control notification system, force commit my changes (ie overwrite the repository - this was long before CVS even) and renable the system again.

Slowly but surely the whole code base was improved (from the most obscure files upwards) and by the time they realized what had happened (weeks later) it was already too late to change it back.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:19 • by G-Spot (unregistered)
foreach(comment.THATMAYHAVESOMEINTERESTINGCONTENT in comments.FROMTHEDAILYWTFFRONTPAGE)

{
if(user.SOCKPUPPETNAME.equals("geoffrey")
{
igsnore();
}

}

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:26 • by Matt Westwood
365116 in reply to 365113
geoffrey:
trtrwtf:
Matt Westwood:

Interesting how fashions change. There's lots of bollocks being talked about single line curly braces at the moment. I think it looks shit, by the way.

Used to be that the Egyptian style, a.k.a the K&R style, was king. Now suddenly it's not.


Style is fashion - do what everyone on your project does, it'll be okay.
K&R is popular in books because vertical line space is expensive in print. On the screen, vertical line space is free, and if it's an issue it's an alarm bell: time to refactor.

I prefer the One True Brace Style (Allman style) because it lets me line up the braces by eye, and makes the blocks more obvious. But whatever, in this world there are certainly bigger things to get worked up about.
Single-line braces are a belt-and-suspenders thing, at best. If you're doing everything else right, they don't make a lot of difference, and they busy up your code. If you're doing everything else wrong, they're not likely to make a lot of difference, and they busy up your code. So don't bother, I say, just do everything else right.


Reminds me of a job I had 15 years ago. I was moved onto a long running project and found myself on the "team" of a real bunch of K&R apologists. Despite my best attempts to educate them as to the merits of single line quotes they forced me to use K&R. Joke was on them though, each day I would secretly convert pieces of the code from K&R to single brace (as well as making some other more aesthetic and functional changes/improvements). Then when they went home each night I would disable the source control notification system, force commit my changes (ie overwrite the repository - this was long before CVS even) and renable the system again.

Slowly but surely the whole code base was improved (from the most obscure files upwards) and by the time they realized what had happened (weeks later) it was already too late to change it back.


What a shitty thing to do.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:29 • by trtrwtf
365118 in reply to 365116
Matt Westwood:
geoffrey:
trtrwtf:
Matt Westwood:

Interesting how fashions change. There's lots of bollocks being talked about single line curly braces at the moment. I think it looks shit, by the way.

Used to be that the Egyptian style, a.k.a the K&R style, was king. Now suddenly it's not.


Style is fashion - do what everyone on your project does, it'll be okay.
K&R is popular in books because vertical line space is expensive in print. On the screen, vertical line space is free, and if it's an issue it's an alarm bell: time to refactor.

I prefer the One True Brace Style (Allman style) because it lets me line up the braces by eye, and makes the blocks more obvious. But whatever, in this world there are certainly bigger things to get worked up about.
Single-line braces are a belt-and-suspenders thing, at best. If you're doing everything else right, they don't make a lot of difference, and they busy up your code. If you're doing everything else wrong, they're not likely to make a lot of difference, and they busy up your code. So don't bother, I say, just do everything else right.


Reminds me of a job I had 15 years ago. I was moved onto a long running project and found myself on the "team" of a real bunch of K&R apologists. Despite my best attempts to educate them as to the merits of single line quotes they forced me to use K&R. Joke was on them though, each day I would secretly convert pieces of the code from K&R to single brace (as well as making some other more aesthetic and functional changes/improvements). Then when they went home each night I would disable the source control notification system, force commit my changes (ie overwrite the repository - this was long before CVS even) and renable the system again.

Slowly but surely the whole code base was improved (from the most obscure files upwards) and by the time they realized what had happened (weeks later) it was already too late to change it back.


What a shitty thing to do.


What, you mean responding to a troll?

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:29 • by Steve The Pirate (unregistered)
365119 in reply to 365095
C-Octothorpe:
That last one is eerily similar to the code-base I inherited about a year ago, except replace all the "safe" if blocks with try/catch blocks...
public static int StringToInt32(string str)

{
try {
return int.parse(str);
}
catch { return 0; }
}
Ahh, now that's a beaute! Or the single return variant:
public static int StringToInt32(string str)

{
int returnValue = "";

try {
returnValue = int.parse(str);
}
catch { }

return returnValue;
}
Now if this "pattern" doesn't scream "I don't give a shit about the quality of my code", then I don't know what does...

That is an interesting value to initialize your int to

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:31 • by Severity One
365120 in reply to 365072
The Mr. T Experience:
TRWTF is listing "French" and "Gay" separately.
You are obviously unfamiliar with Alizée.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:37 • by Tyler Durdin (unregistered)

public static string GetStringValue(object obj)
{
if (obj == null)
{
return "";
}
if ((obj == null))
{
return "";
}
if (!(obj == null))
{
return obj.ToString();
}
else
{
return "";
}
}


The first rule of GetStringValue is return "" for (obj == null).
The second rule of GetStringValue is return "" for (obj == null)!
The third rule of GetStringValue is if !(obj == null) - you HAVE to fight.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:38 • by The Mr. T Experience (unregistered)
365123 in reply to 365120
Severity One:
The Mr. T Experience:
TRWTF is listing "French" and "Gay" separately.
You are obviously unfamiliar with Alizée.
Do you mean the singer? Why? because you think she's hot? I suppose you also think that Harry potter movies aren't gay because you have a crush on that little girl Emma what's-her-name?

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:39 • by PedanticCurmudgeon
365124 in reply to 365098
Matt Westwood:
C-Octothorpe:
boog:
private var languageLabels:ArrayCollection = new ArrayCollection(

"English",
"German",
"French",
"Zunesis"
);
FTFY
Oh silly me. I thought that was a list of languages, not genders... My bad.
+1

In order of presentation: "Male", "Neuter", "Female", "Bored Teenager with nothing better to do."
FTFY

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:39 • by C-Octothorpe
365125 in reply to 365119
Steve The Pirate:
C-Octothorpe:
That last one is eerily similar to the code-base I inherited about a year ago, except replace all the "safe" if blocks with try/catch blocks...
public static int StringToInt32(string str)

{
try {
return int.parse(str);
}
catch { return 0; }
}
Ahh, now that's a beaute! Or the single return variant:
public static int StringToInt32(string str)

{
int returnValue = "";

try {
returnValue = int.parse(str);
}
catch { }

return returnValue;
}
Now if this "pattern" doesn't scream "I don't give a shit about the quality of my code", then I don't know what does...

That is an interesting value to initialize your int to
I tried CTRL-SHIFT-B-ing the text editor, but it didn't report any build errors.

I blame Obama, really...

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:43 • by Dave (unregistered)
        if (obj == null)

{
return "";
}
if ((obj == null))
{
return "";
}
Clearly this guy is one of those who thought "something isn't working; let me try this". For some reason the technology world (and maybe the rest of the world?) is full of "try this" people who never bother to figure out what's actually wrong. You'll find them on every helpless desk: Did you try rebooting?

If you're a "try this" guy, I have only one thing to say to you: Did you try thinking?

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:43 • by Matt Westwood
365128 in reply to 365118
trtrwtf:
Matt Westwood:
geoffrey:
trtrwtf:
Matt Westwood:

Interesting how fashions change. There's lots of bollocks being talked about single line curly braces at the moment. I think it looks shit, by the way.

Used to be that the Egyptian style, a.k.a the K&R style, was king. Now suddenly it's not.


Style is fashion - do what everyone on your project does, it'll be okay.
K&R is popular in books because vertical line space is expensive in print. On the screen, vertical line space is free, and if it's an issue it's an alarm bell: time to refactor.

I prefer the One True Brace Style (Allman style) because it lets me line up the braces by eye, and makes the blocks more obvious. But whatever, in this world there are certainly bigger things to get worked up about.
Single-line braces are a belt-and-suspenders thing, at best. If you're doing everything else right, they don't make a lot of difference, and they busy up your code. If you're doing everything else wrong, they're not likely to make a lot of difference, and they busy up your code. So don't bother, I say, just do everything else right.


Reminds me of a job I had 15 years ago. I was moved onto a long running project and found myself on the "team" of a real bunch of K&R apologists. Despite my best attempts to educate them as to the merits of single line quotes they forced me to use K&R. Joke was on them though, each day I would secretly convert pieces of the code from K&R to single brace (as well as making some other more aesthetic and functional changes/improvements). Then when they went home each night I would disable the source control notification system, force commit my changes (ie overwrite the repository - this was long before CVS even) and renable the system again.

Slowly but surely the whole code base was improved (from the most obscure files upwards) and by the time they realized what had happened (weeks later) it was already too late to change it back.


What a shitty thing to do.


What, you mean responding to a troll?


Good call. It was a knee-jerk reaction. He's a jerk, I kneed him.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:47 • by C-Octothorpe
365129 in reply to 365128
Matt Westwood:
trtrwtf:

What, you mean responding to a troll?
Good call. It was a knee-jerk reaction. He's a jerk, I kneed him.
+1

*added to personal vocabulary*

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:51 • by Jerry (unregistered)
If those shagnasty long variable names didn't come from PeopleSoft, they must at least have been autogenerated by the same convert-mainframe-COBOL-directly-to-web-2.0 utility.

Re: Useless Functions, Extreme Naming, and More

2011-10-31 12:54 • by Bananas (unregistered)
365131 in reply to 365093
Utterly Confused:
>#define TASK_RATE_ONE_SECOND (TASK_RATE * 40)

What would this mean, the number of TASK_RATE tasks in one second? If so, yeah, this is 200 for a TASK_RATE of 5 ms BUT it should be computed as 1000/TASK_RATE ***CONFUSED***
Whoever created this mess fell into the all-too-common trap of using the word "rate" when he clearly meant "interval" instead. If you increase the value of that thing he named "rate" you will decrease the actual rate at which things happen.

Does that help?
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment