• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Shocking code

 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure if this will work - but I thought people may find it amusing to see some funny code that people have come across - so I thought I would give it a go with some prize snippets I have encountered. My first one comes from a Servlet...



Anyone else have some interesting examples?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not really that strange, is it? I mean, what I have done is:



Would you call that Shocking?
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And the problem with this code is what? It is the exact code found on page 25 of the book, Java Servlet Programming" by Jason Hunter.
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Second one - I especially liked this...

 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps the first isnt that bad - it just seemed unintuitive to me.

I use the same method as you Gregg - I put my code in a seperate method for both doGet and doPost.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rick Beaver:
Second one - I especially liked this...



The method and variable names are strange, but the work being done isn't that strange. If isSet is private you'd still need a method to check it's boolean state, would you not?

So I am assuming you just mean the variable and method names are odd. If that is the case, then yes, very. However, you aren't really shocking anyone yet. I've seen a lot worse.
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gregg Bolinger:



The method and variable names are strange, but the work being done isn't that strange. If isSet is private you'd still need a method to check it's boolean state, would you not?

So I am assuming you just mean the variable and method names are odd. If that is the case, then yes, very. However, you aren't really shocking anyone yet. I've seen a lot worse.[/QB]
</blockquote>

My point is that this method could be just



So perhaps my examples are poor? Oh well, I was just trying to perhaps get a smile.

Maybe you could post some examples that are more amusing?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rick Beaver:
Oh well, I was just trying to perhaps get a smile.



Well, you've acomplished that at least. Now stop fooling around and go answer my latest thread in JSF.
[ June 01, 2005: Message edited by: Gregg Bolinger ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best source for examples of unbelievably bad code is here. You can waste hours there and have a good laugh.
[ June 01, 2005: Message edited by: Ernest Friedman-Hill ]
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a 'well-known' code example that probably looks pretty strange at first sight:
 
Ranch Hand
Posts: 872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see a lot of this type of code in OOP, but sometime it is hard to see, explain or find.
 
It's exactly the same and completely different as this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic