|
You get my up-vote for the idea, but making the idea more general-purpose means, imho, not being able to use an Extension method with generics, since the 'this parameter of an Extension method cannot be declared 'ref, or 'out.
How about this (based on the code example in my previous reply to this thread)
using System;
namespace InMemoriamMaunder
{
public enum DodgyResult
{
ResultNull,
ResultOkay,
ResultError
}
public static class DodgyUtilities
{
public static DodgyResult TryGetValueFromDodgy<T1,T2>(T1 t1, ref T2 t2, Func<T1,T2> func)
{
try
{
t2 = func(t1);
if (t2 == null)
{
return DodgyResult.ResultNull;
}
else
{
return DodgyResult.ResultOkay;
}
}
catch (Exception)
{
return DodgyResult.ResultError;
}
}
}
}
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008
|
|
|
|
|
No programming questions in the Lounge!
Chris Maunder wrote: Or am I setting a new standard for lazy, shameful programming here this hot, lazy afternoon?
Surely you jest! It's only 117° today, but we're supposed to warm up for the weekend.
Will Rogers never met me.
|
|
|
|
|
how about setting that as default for the whole app... you could use a constant like #ON_ERROR_RESUME_NEXT = true;
|
|
|
|
|
Why not make it a compiler flag that can be set once per file.
#pragma OnError ResumeNext
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
I just love to imagine the absolute mayhem such a pragma would allow.
cheers
Chris Maunder
|
|
|
|
|
Just NO!
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
Chris Maunder wrote: string result = DodgyApi.GetValue*();
What about
string result = DodgyApi.GetValue*(value);
as you don't always want the type default. Not sure how we define my value for reference types, maybe it could use the C# new type { prop1 = val1, ...} paradigm?
Anyway, no, bad idea. I want to fire people who silently swallow exceptions. At least, the code should be logging at some level, "hey, DodgyApi failed, using default value x" so that (in theory) somebody could investigate and make the api somewhat less dodgy.
|
|
|
|
|
Don't use DodgyApi directly.
string result = MyDodgyApiWrapper.GetValue();
Your wrapper can log any exceptions, provide a reasonable default value "Service unavailable. Try back later.", etc.
If a better backend evolves later, just update your wrapper.
|
|
|
|
|
Too much time on your hands?
|
|
|
|
|
cheers
Chris Maunder
|
|
|
|
|
Swallowing excepsions is bad style. If the function throws different exceptions, there may be strong need to react to them differently.
|
|
|
|
|
Hands down, this has to be the most hilarious computer article I’ve seen in a long time. Just look at the number one asked for qualification. If you really want a laugh, read the text of the article, and especially the first of the three big takeaways at the end of the article
Study of IT job postings on Indeed reveals trends important for all tech professionals[^]
Ya, this was in today's CodeProject daily news.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
Awesome!
Customer service is over twice as important as attention to detail. So: it doesn't have to work - you just have to be really good at convincing them that this is normal.
Maybe next time they need to breakdown "IT" into smaller bits that author can chew on. That's like saying "Qualifications mentioned in Construction" and having a list like
- Draftsmanship
- Excavation
- Capital fund raising
- Truck maintenance
- Metallurgy
- Dirt
- Building things
cheers
Chris Maunder
|
|
|
|
|
Quote: Customer service is over twice as important as attention to detail
Sadly, this is true. When I last hired a help desk support person, my manager was adamant that was the main criteria. If they didn't know the answer they could easily pass it to the next level, but a customer would feel good with the good PR and not notice nothing got fixed!
Luckily for me the person I hired had both skills.
|
|
|
|
|
Chris Maunder wrote: Customer service is over twice as important as attention to detail. So: it doesn't have to work - you just have to be really good at convincing them that this is normal.
So what you're saying is I should be focusing on a job in Customer Service.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
You just made me spray beer on the screen.
Yeah...no.
cheers
Chris Maunder
|
|
|
|
|
I was saddened to know that my experties in VMWare doesn't count for squat.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: was saddened to know that my experties in VMWare doesn't count
Apparently they know about your spelling issues.
Will Rogers never met me.
|
|
|
|
|
What spelling issues? I have more than one experty.
/ravi
|
|
|
|
|
Sorry to be pedantic, but that one got me
If you're not familiar with programming API interfaces it's time to learn: it's by far the most highly sought skill from Indeed job posters. If you're not familiar with acronyms it' time to learn... or at least look them up
(yes|no|maybe)*
"Fortunately, we don't need details - because we can't solve it for you." - OriginalGriff
|
|
|
|
|
All I get from that story is that Igloo is looking for PR.
The article is fluff.
|
|
|
|
|
|
It seems to this mere mortal that Putin's Russia is heading in the direction of the cuddly East Germans.
veni bibi saltavi
|
|
|
|
|
What's weird is that the "normal" Russians seem to be believing everything he says...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Nothing unusual about that. Americans are the same way, only I think stupider. Maybe you should listen to John Mearsheimer on youtube--You would have a much better understanding. As it is you are showing your ignorance. Did you really expect either Russians or Americans or citizens of any country to be any smarter than they were in the past. If Putin was the American president, the American would love him. Americans love the hard stance. All countries love it when they perceive their leader is taking the hard stance. Obama is constantly criticized for not taking the hard stance (even though he really is taking a stupid hard stance).
|
|
|
|