Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 24th, 2007, 7:37 PM   #1
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Think

I recently saw an example of a "design pattern". This pattern used 151 lines of code (281, counting comments) to provide a class that could store or return one of the values, True, or False.

An example of invocation?
YesNoFactory.getFactoryInstance().YES.getDescription().equals(array[0].toUpperCase());

I really think I could beat this with a bool or an int.

Don't fall for BS; think for yourselves. Support it by learning, not by high-priestly worship of false, self-anointed gurus. You don't need to kiss the hem of their robe, much less their ass, if you just look around and think.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 24th, 2007, 7:58 PM   #2
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
Re: Think

That's an impressive WTF. Did you find it in real code, or is it a joke?

>I really think I could beat this with a bool or an int.
How? It looks like that code is just a glorified no-op, if all it does is compare the string against "YES" and ignore the result.

>Don't fall for BS; think for yourselves.
That reminds me of the time that I laughed in a guy's face when he explained design patterns to me.
__________________
Even if the voices aren't real, they have some pretty good ideas.
Narue is offline   Reply With Quote
Old Nov 24th, 2007, 8:52 PM   #3
null_ptr0
12 years old
 
Join Date: Nov 2007
Posts: 104
Rep Power: 0 null_ptr0 is an unknown quantity at this point
Re: Think

He found it, it was in someone's sig.
null_ptr0 is offline   Reply With Quote
Old Nov 24th, 2007, 11:09 PM   #4
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Re: Think

TextEncoding.getSystemDefault().createTextWriter(
     EnvironmentManager.getDefaultInstance().
         getStandardIOFactory().createOutputStream()).
     write(LocalizationManager.getInstance().
         getTranslatedStringForCurrentCulture("Hello World").
         concat(EnvironmentManager.getSystemNewLine()));
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Nov 25th, 2007, 5:05 AM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Think

It wasn't in someone's sig. It was a blog post on a blog called something similar to "How ugly is this." It's nice to know you aren't really looking over my shoulder, or living in my head, null. I'm too young to commit suicide.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 25th, 2007, 6:03 AM   #6
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
Re: Think

It was on The Daily WTF earlier this month. Great blog.

Edit: Oh, right, its called "Worse Than Failure" now. I liked the old name better.
ZenMasterJG is offline   Reply With Quote
Old Nov 25th, 2007, 8:12 PM   #7
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
Re: Think

Maybe that class parses values for yes and no, i.e

"yes" -> "Yes"
"y" -> "Yes"
"true" -> "Yes"
"definitely" -> "Yes"


In which case, 151 lines of code may not be bad.
Harakim is offline   Reply With Quote
Old Nov 25th, 2007, 9:21 PM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Think

Well, son, whatever you think. I'm sure you can find a fool to cut your a check for a few cents on the dollar....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 26th, 2007, 6:47 PM   #9
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
Re: Think

Quote:
Originally Posted by Harakim View Post
Maybe that class parses values for yes and no, i.e
"yes" -> "Yes"
"y" -> "Yes"
"true" -> "Yes"
"definitely" -> "Yes"
If thats the case, its a solution to a problem that should not have existed in the first place. And if you did have to solve it, you could use a one line regex instead of some big ugly behemoth.
ZenMasterJG is offline   Reply With Quote
Old Nov 26th, 2007, 7:13 PM   #10
King
Professional Programmer
 
King's Avatar
 
Join Date: Jan 2006
Location: Ontario, Canada
Posts: 380
Rep Power: 3 King is on a distinguished road
Re: Think

Quote:
Originally Posted by Harakim View Post
Maybe that class parses values for yes and no, i.e

"yes" -> "Yes"
"y" -> "Yes"
"true" -> "Yes"
"definitely" -> "Yes"


In which case, 151 lines of code may not be bad.
If someone actually did that they would have to be mentally retarded, and even then it would not be acceptable.
__________________
I am Addicted to Linux!
King is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:02 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC