Click here to Skip to main content

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralWhy not: // just shoot me!memberesaulsberry23hrs 40mins ago 
try
{
    account.Save();
}
catch { ; } //Not good!
Mad | :mad:
GeneralRe: Why not: // just shoot me!memberPualee22hrs 14mins ago 
At least there are comments.
GeneralRe: Why not: // just shoot me!protectorOriginalGriff21hrs 26mins ago 
I can think of a few comments myself...
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

GeneralRe: Why not: // just shoot me!memberPankaj Nikam13hrs 2mins ago 
Guess programmer was hungry thats why he "ate" the exception Big Grin | :-D
Always Keep Smiling.
Yours Pankaj Nikam

GeneralRe: Why not: // just shoot me!memberOshtri Deka10hrs 13mins ago 
Relax.
This is just sweeping under the rug.
 

It could be worse.
Mislim, dakle jeo sam.

GeneralRe: Why not: // just shoot me!memberGary Wheeler7hrs 11mins ago 
I'm impressed they wasted the energy on a surplus semicolon.
Software Zen: delete this;

GeneralRe: Why not: // just shoot me!memberenglebart5hrs 49mins ago 
They might have a style rule that enforces:
"catch block cannot be empty"
 
Warning: Empty catch block.
 
ftfy: ";"
GeneralRe: Why not: // just shoot me!memberGary Wheeler5hrs 40mins ago 
... which just demonstrates how misleading style enforcement can be.
Software Zen: delete this;

GeneralRe: Why not: // just shoot me!memberesaulsberry5hrs 29mins ago 
Big Grin | :-D What kills me is the comment. It would have taken the same effort to say Logger.Log(ex);
GeneralRe: Why not: // just shoot me!memberagolddog4hrs 53mins ago 
I'm trying (in vain so far) to think up any scenario where the context around this might make this o.k. For example, something like:
 
int pageIndex = 0;
try {
    pageIndex = int.TryParse(Request[pageNum])
} catch (Exception e) {
    Logger.info("Page Index of " + Request[pageNum] + " invalid, using " + pageIndex.ToString());
}
 
(Of course, I'd use Int.TryParse instead and null-check the request variable)
 
But, you get the idea--some scenario where you can continue to operate with default data given an unexpected condition. I can't think of any situation where the missing context makes it o.k. to swallow an exception trying whatever a Save operation does.
GeneralRe: Why not: // just shoot me!memberesaulsberry4hrs 48mins ago 
In this case it's just plain sloppy, lazy, and wrong. It should log and throw, allowing the error to propagate to the global error handler. The object's been validated so if the save fails it's a critical failure somewhere in the system, like the database is down. Eating the error when a save fails is never the right thing to do. The user blissfully goes about their business because the save "worked" but it didn't. Wrong, wrong, wrong.
GeneralRe: Why not: // just shoot me!memberStatementTerminator4hrs 37mins ago 
I can think of situations where it might be appropriate to do something like that.
 
For instance, suppose you are implementing a "like" button or something similar. It's not critical that it works and let's assume that it's unreliable for reasons beyond the programmer's control, like maybe it depends on an external service which is not always available.
 
So in that case maybe it's OK to swallow the exception since it's not unusual and nothing will really break if it fails, so you just silently fail and the user can try again if they want. There aren't many situations like this in programming though, and you still should probably log the exceptions.
 
I'm pretty sure that something like account.Save() is a bit too important to treat this way, though.
GeneralRe: Why not: // just shoot me!memberStatementTerminator4hrs 45mins ago 
Looks to me like the original programmer was too lazy to handle an exception, and another programmer came along and added the helpful "Not good!" comment, and left it like that. I don't know which programmer to hate more.
 
Five bucks says that account.Save() has a return value indicating success.
JokeRe: Why not: // just shoot me!memberRafagaX3hrs 26mins ago 
Well if saving doesn't work now, it could work later... Poke tongue | ;-P
CEO at:
- Rafaga Systems
- Para Facturas
- Modern Components
for the moment...

GeneralCan't people read the form description anymore?memberRob Grainger16 May '13 - 3:20 
I notice that a fair few of the recent posts here seem out of place.
 
Can't people read?
 
ps. I guess that by posting this, I now have to include myself in that category, but I'm hoping to be indulged.
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.

GeneralRe: Can't people read the form description anymore?professionalPIEBALDconsult16 May '13 - 4:21 
Two wrongs don't make a right. Roll eyes | :rolleyes:
JokeRe: Can't people read the form description anymore?memberCarlos Fonseca16 May '13 - 4:31 
But three lefts do.
 
Poke tongue | ;-P
 
(well, someone had to do it!)
Quidquid latine dictum sit, altum viditur.

GeneralRe: Can't people read the form description anymore?professionalPIEBALDconsult16 May '13 - 4:37 
I resisted doing it myself.
GeneralRe: Can't people read the form description anymore?memberBrainiacV4hrs 56mins ago 
And remember that there will always be a future in computer maintenance...
 
Assuming you were quoting the Deteriorata.
Psychosis at 10
Film at 11
 
Those who do not remember the past, are doomed to repeat it.
Those who do not remember the past, cannot build upon it.

GeneralRe: Can't people read the form description anymore?memberBobJanova16 May '13 - 4:43 
It was better when it was the Hall of Shame, if you ask me.
GeneralRe: Can't people read the form description anymore?memberDave Calkins16 May '13 - 7:41 
Most of the time I just click the links from the main page to get to various threads, having no idea which forum they're in or what on earth the forum description is if any Smile | :)
JokeRe: Can't people read the form description anymore?professionalRhys Gravell17 May '13 - 4:02 
Apparently some people can't even spell forum anymore let alone read a description about its purpose... Poke tongue | ;-P
Rhys
 
"If you ever start taking things too seriously, just remember that we are talking monkeys on an organic spaceship flying through the Universe"

GeneralRe: Can't people read the form description anymore?memberRob Grainger9hrs 55mins ago 
Well I had to have some kind of horror in their to justify posting to this forum Wink | ;-)
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
Alan Kay.

GeneralRe: Can't people read the form description anymore?memberBrainiacV4hrs 55mins ago 
He was expecting the Intellisense to complete it for him.
Rhys Gravell wrote:
Apparently some people can't even spell forum

Psychosis at 10
Film at 11
 
Those who do not remember the past, are doomed to repeat it.
Those who do not remember the past, cannot build upon it.

JokeRe: Can't people read the form description anymore?memberryanb314hrs 22mins ago 
Quote:
Can't people read?
I'm fine, how are you?
There are only 10 types of people in the world, those who understand binary and those who don't.

GeneralCode Safety and The .Net CLR & Java Runtime [modified]memberdusty_dex9 May '13 - 12:36 
Apologies if this subject has already been discussed before.
 
After stumbling upon last September's Best C# Article NET-CLR-Injection-Modify-IL-Code-during-Run-time and learning about endless security issues with the Java Runtime.
 
Are these platforms actually safer than conventional compiled executables?
 
Isn't the whole point of Data Execution Prevention (DEP) meant to stop run-time modification of running code? The CLR/JAVA Runtime engines have the only *native* code that DEP has any direct control of, but they are allowed to run without question, because of some dubious assumption that code for a virtual cpu/machine can do no real damage.
 
Maybe I'm wrong, but I can't help thinking that code under direct control of the 'real' cpu is safer than these virtualized runtime environments. Suspicious | :suss:
 
I'm not fully versed in .NET or Java coding. Anyone care to shed more light on the subject.



modified 9 May '13 - 20:02.

GeneralRe: Code Safety and The .Net CLR & Java RuntimememberLloyd Atkinson9 May '13 - 13:31 
dusty_dex wrote:
The CLR/JAVA Runtime are the only executable code DEP has any direct control of

 
Nope not true at all. It has full control over native code too. Also, don't forget that these runtimes are written in native code.
 
Just as a point of interest, some CPU's have a hardware based DEP[^]
           .-.
          |o,o|
       ,| _\=/_      .-""-.
       ||/_/_\_\    /[] _ _\
       |_/|(_)|\\  _|_o_LII|_
          \._./// / | ==== | \
          |\_/|"` |_| ==== |_|
          |_|_|    ||" ||  ||
          |-|-|    ||LI  o ||
          |_|_|    ||'----'||
         /_/ \_\  /__|    |__\

GeneralRe: Code Safety and The .Net CLR & Java Runtimememberdusty_dex9 May '13 - 13:57 
Sorry, my wording could have been clearer. D'Oh! | :doh:
 
[I've made a minor modification to the original post]
 
I know that the DEP handles *all* native code, but that's what I was getting at. The runtimes are native code but I wanted to know whether the MSIL code/ Java Bytecode is kept in the dcache or icache along with native code.
 
I thought native code, unless specifically marked as shared would otherwise be read-only and not modifiable at runtime. Which led me to wonder about the location .NET/Java bytecodes and the whole self-modifying code (code injection) problem, with the apparent side-stepping of DEP protection.
 
Smile | :)


GeneralRe: Code Safety and The .Net CLR & Java RuntimeprofessionalPIEBALDconsult9 May '13 - 16:09 
Wrong forum.
GeneralRe: Code Safety and The .Net CLR & Java Runtimememberdusty_dex9 May '13 - 23:55 
So which forum?
 
I based my decision on the WORST/BEST PRACTICES which is mentioned at the top.


GeneralLife of Software DevelopermemberJuhi Paunikar6 May '13 - 2:32 
I think the life of software developer is a nothing but "The journey between LOGIN & LOGOUT" Wink | ;)
What is your opinion??
eNJOY c0ding....

GeneralRe: Life of Software Developermemberradioman.lt6 May '13 - 3:41 
it's just a job, and it doesn't count as life Sniff | :^)
d{^__^}b - it's time to fly

GeneralRe: Life of Software DevelopermemberJuhi Paunikar6 May '13 - 20:18 
I agree it doesn't count life but it is not a part of life??
eNJOY c0ding....

GeneralRe: Life of Software Developermemberradioman.lt6 May '13 - 20:41 
it's a waste of life, mostly coding useless stuff D'Oh! | :doh:
d{^__^}b - it's time to fly

GeneralRe: Life of Software DevelopermemberJuhi Paunikar6 May '13 - 21:01 
I think you had something bad experience about cOding.
eNJOY c0ding....

GeneralRe: Life of Software Developermemberradioman.lt6 May '13 - 21:06 
i don't see whats so 'enjoyable', it's sunny warm day, and it's wasted sitting in the office... D'Oh! | :doh:
d{^__^}b - it's time to fly

GeneralRe: Life of Software DevelopermemberJuhi Paunikar6 May '13 - 21:14 
Take a break and spend time with friends and family.
it will remove your stress as you mentioned in you trailing message!!! Smile | :)
eNJOY c0ding....

GeneralRe: Life of Software Developermemberradioman.lt6 May '13 - 21:19 
it would, but too bad i have to be in the office, your solution doesn't work, 8h still to waste and thats it for today Laugh | :laugh:
d{^__^}b - it's time to fly

GeneralRe: Life of Software DevelopermemberJuhi Paunikar6 May '13 - 22:32 
Hey...Leave this job if you are not happy with it.
do whatever which gives you happiness otherwise be happy with whatever you are doing.... OMG | :OMG:
eNJOY c0ding....

GeneralRe: Life of Software Developermemberradioman.lt6 May '13 - 22:40 
i need the money, can't leave ;/
d{^__^}b - it's time to fly

GeneralRe: Life of Software DevelopermemberJuhi Paunikar6 May '13 - 23:07 
Then don't be upset...
eNJOY your work,it's an only single way to keep yourself happy. Wink | ;)
BTW you do have so many options to earn money except development & coding Blush | :O
eNJOY c0ding....

GeneralRe: Life of Software DeveloperprofessionalSuvabrata Roy6 May '13 - 4:22 
Its all about creativity.
 
You can reach destination in several ways but which one is shortest and flexible that is where good developer involved.
Laugh | :laugh:
Life is all about share and care...

GeneralRe: Life of Software DevelopermemberDennis E White6 May '13 - 4:35 
so when they enter into management (without coding) does that mean they logout??
 
if that is the case then you have to allow for multiple logins. I did the management route a few years back and after a couple of years I realized I was miserable and wanted to program. Big Grin | :-D
as if the facebook, twitter and message boards weren't enough - blogged

GeneralRe: Life of Software DeveloperprofessionalPIEBALDconsult6 May '13 - 4:54 
Wrong forum.
GeneralRe: Life of Software DevelopermemberJuhi Paunikar6 May '13 - 20:17 
Will you please explain why it is wrong forum?
eNJOY c0ding....

GeneralRe: Life of Software DevelopermemberPeter_in_27806 May '13 - 22:39 
...from the top of the page...
 
The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.
 
We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.
 
Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.
 
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

GeneralRe: Life of Software DevelopermemberJuhi Paunikar6 May '13 - 23:10 
you have copied all thing from the top of the page... Poke tongue | ;-P
eNJOY c0ding....

GeneralRe: Life of Software DeveloperprotectorPete O'Hanlon7 May '13 - 0:53 
But have you read it yet? Do you understand it?
I was brought up to respect my elders. I don't respect many people nowadays.

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralRe: Life of Software DevelopermemberJuhi Paunikar7 May '13 - 1:04 
Ya sir.and i don't think i have posted some wrong forum.shall i delete it?
eNJOY c0ding....

GeneralRe: Life of Software DeveloperprotectorPete O'Hanlon7 May '13 - 1:07 
Leave it now, but in future pay attention to what the purpose of the forum is that you are posting in to. This forum is purely for code.
I was brought up to respect my elders. I don't respect many people nowadays.

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 21 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid