|
Fair enough. It is a bit of a pain to get utf16 out of it - you have to cast to []rune, then use unicode/utf16 to get []uint16, and then use encoding/binary to turn that into a []byte with whichever endianness you need.
|
# ? Nov 29, 2012 16:03 |
|
|
# ? May 16, 2024 12:21 |
|
The only word I have in my vocabulary to describe the following formatting of java code, would have to be "Horrifying": code:
|
# ? Nov 30, 2012 04:45 |
slam5000 posted:This was written by a friend of mine who's new to programming, and even though he's new, I have no idea where he learned (or rather got the idea in his head) that it's ok to just throw in blocks in wherever the hell you want, and put your semi-colons at the START of the line! I'm more interested in what purpose he gives those squiggly {} things.
|
|
# ? Nov 30, 2012 08:26 |
|
Tilt your head to the left.
|
# ? Nov 30, 2012 08:58 |
|
So this is the person who jslint was made for. Yes I know Java is not Javascript, but he needs his feelings hurt the jslint way.
|
# ? Nov 30, 2012 09:08 |
|
I came across something like this today, in some older code written by one of our more senior programmers that's still being used for live, production work:Perl code:
|
# ? Nov 30, 2012 09:46 |
|
slam5000 posted:The only word I have in my vocabulary to describe the following What the gently caress.
|
# ? Nov 30, 2012 09:51 |
|
slam5000 posted:The only word I have in my vocabulary to describe the following Every time I look at this I am increasingly more appalled that this guy is apparently using an editor with a <35 character line limit.
|
# ? Nov 30, 2012 10:08 |
|
Extortionist posted:I came across something like this today, in some older code written by one of our more senior programmers that's still being used for live, production work: quote:Every time I look at this I am increasingly more appalled that this guy is apparently using an editor with a <35 character line limit. pigdog fucked around with this message at 10:46 on Nov 30, 2012 |
# ? Nov 30, 2012 10:44 |
|
pigdog posted:Came for awesome perl horrors, left slightly disappointed. Sure he could have just gone for %somehash = @somearray and worked it from there, but hey, TMTOWTDI. Sane and comprehensible is a tall order for Perl programs in the first place. Let me guess, and no one told them that you can drag out the size of a textbox in modern browsers?
|
# ? Nov 30, 2012 15:07 |
|
Or just copy and paste into an actual text editor.
|
# ? Nov 30, 2012 16:04 |
|
pigdog posted:Came for awesome perl horrors, left slightly disappointed. Sure he could have just gone for %somehash = @somearray and worked it from there, but hey, TMTOWTDI. Sane and comprehensible is a tall order for Perl programs in the first place. Anyway, probably more impressive in the program were the ~200 regular expressions, all trying to match variations of the same relatively simple string. Stuff like: Perl code:
But I may be being overly harsh on his code because the program doesn't really work at all, and the fact that it doesn't work creates probably an extra few day's worth of incredibly tedious work a month for a couple unlucky people (though not me, anymore).
|
# ? Nov 30, 2012 18:16 |
I'm starting to notice a slight trend in one of our developers' scripts.code:
|
|
# ? Nov 30, 2012 20:49 |
|
Manslaughter posted:I'm starting to notice a slight trend in one of our developers' scripts. Tell him about Pokemon Exception Handling and why it's bad.
|
# ? Nov 30, 2012 21:01 |
|
Ithaqua posted:Tell him about Pokemon Exception Handling and why it's bad. My favorite is still echo "mail send... ERROR"; // or use booleans here. Ithaqua posted:Tell him about Pokemon Exception Handling and why it's bad. I don't know why they used Pokemon Exception Handling as the name of that (anti-)pattern, because to be pretty honest that kind of exception handling is exactly what made Pokemon entertaining. An attempt at googling where that came from (since "// DO something") did reveal this gem, though: code:
It makes a little more sense if you read the comments, but at first glance (and even afterwards) it's just a little worthy.
|
# ? Nov 30, 2012 21:40 |
|
Zamujasa posted:I don't know why they used Pokemon Exception Handling as the name of that (anti-)pattern, because to be pretty honest that kind of exception handling is exactly what made Pokemon entertaining. It's because you gotta catch 'em all!
|
# ? Nov 30, 2012 21:46 |
It's not even the catch(Exception) that scares me. It's the fact that the guy looked at that, thought "yeah, I could throw or something here, but I'll just let it fly " and then published. It's doing exactly the opposite of something.
|
|
# ? Nov 30, 2012 22:00 |
|
yaoi prophet posted:It's because you gotta catch 'em all! Yup. The worst offender I've ever seen just did this: code:
|
# ? Nov 30, 2012 22:00 |
Ithaqua posted:Yup. The worst offender I've ever seen just did this: That's more like Iraqi exception handling. "There is no exceptions in this program. None. Ever."
|
|
# ? Nov 30, 2012 22:04 |
|
I posted about in an earlier iteration of this thread years ago but I can beat even that: (to paraphrase,) C++ code:
|
# ? Dec 1, 2012 00:15 |
|
Ithaqua posted:Yup. The worst offender I've ever seen just did this: Holy poo poo. Do... like professional programmers, any of them actually do this in production. Because that is the just the most braindead instance of coding by coincidence I've ever seen. Throw out the exceptions, she'll be right, we'll eventually have a working product.
|
# ? Dec 1, 2012 00:21 |
|
The only thing that code does is make the program exit cleanly when there's an uncaught exception rather than report an error. It's dumb, but unless it's being called from a batch file that actually bothers to check exit codes it's unlikely to actually cause any problems beyond making it harder to debug things.
|
# ? Dec 1, 2012 01:00 |
|
Plorkyeran posted:The only thing that code does is make the program exit cleanly when there's an uncaught exception rather than report an error. It's dumb, but unless it's being called from a batch file that actually bothers to check exit codes it's unlikely to actually cause any problems beyond making it harder to debug things. But why would you do that? What's the benefit when you're still going to have to figure out what the exception is?
|
# ? Dec 1, 2012 01:04 |
|
Maluco Marinero posted:Holy poo poo. Do... like professional programmers, any of them actually do this in production. Because that is the just the most braindead instance of coding by coincidence I've ever seen. Throw out the exceptions, she'll be right, we'll eventually have a working product. Yes, this was done by a professional programmer and it was production code. Some people never learn good practices by never being exposed to them or bothering to learn about them. That's okay in a young developer, you can usually beat sense into them. The guys with 20 years of experience who suck are the really dangerous ones. The code example I gave above was like that from top to bottom. Every method started with a try block and ended with an empty catch. It was a program that was supposed to be run 24/7 (it wasn't a service because that's harder than a console application run on the task scheduler), so I guess the developer responsible never wanted it to crash. Note: the application did not work very well or reliably for some reason. But it never crashed! New Yorp New Yorp fucked around with this message at 01:51 on Dec 1, 2012 |
# ? Dec 1, 2012 01:48 |
|
I've got to imagine that people who blindly catch every exception and don't even log it have never had to support their own programs over the long haul. I don't see how else they could continue such a practice.
|
# ? Dec 1, 2012 02:13 |
|
Freakus posted:I've got to imagine that people who blindly catch every exception and don't even log it have never had to support their own programs over the long haul. I don't see how else they could continue such a practice. I think most people just don't know any better. They don't know it can be done better. I worked on a project once where a 'try/except/pass' pattern could be found once every dozen lines or so. We were constantly having to fix stupid bugs and sometimes it would take a whole week to track down a single bug. But everyone there just thought that was how the job of software developer is supposed to be. Its sort of like how some people spend their whole lives working for $8 an hour at Walmart instead of learning a skill that will allow them to make hundreds of dollars an hour because they just see their life as what it is and can't imagine anything else.
|
# ? Dec 1, 2012 07:20 |
|
C# code:
|
# ? Dec 1, 2012 10:46 |
|
Ithaqua posted:Yup. The worst offender I've ever seen just did this: Could be worse... Could be code:
|
# ? Dec 1, 2012 15:52 |
|
Maluco Marinero posted:Holy poo poo. Do... like professional programmers, any of them actually do this in production. Because that is the just the most braindead instance of coding by coincidence I've ever seen. Throw out the exceptions, she'll be right, we'll eventually have a working product. I've had a manager ask for exactly that before because "we can't crash in production".
|
# ? Dec 1, 2012 16:12 |
|
Aleksei Vasiliev posted:
It's been several years since I dabbled in C#, but... how does this happen? Is this just flat-out bug or is there some remotely rational explanation that I'm missing here?
|
# ? Dec 1, 2012 16:15 |
|
Hughlander posted:Could be worse... Could be You could put actual exception handling code inbetween these { } at the catch statement, and for most programs, end up with excellently handled exceptions.
|
# ? Dec 1, 2012 16:16 |
|
Flobbster posted:It's been several years since I dabbled in C#, but... how does this happen? Is this just flat-out bug or is there some remotely rational explanation that I'm missing here? http://nitoprograms.blogspot.ca/2009/11/icollection-isreadonly-and-arrays.html Short answer is that arrays in C# implement multiple interfaces with conflicting definitions of IsReadOnly.
|
# ? Dec 1, 2012 18:26 |
|
pigdog posted:You could put actual exception handling code inbetween these { } at the catch statement, and for most programs, end up with excellently handled exceptions. Yeah, that's what I was thinking. Is it so bad to throw exceptions up the call stack until you pass it off to an error handling class? If so, what's a better way to handle exceptions?
|
# ? Dec 2, 2012 01:40 |
|
Handle exceptions as appropriate when the exception is recoverable and expected. It's fine to handle exceptions in the main, so long as "handling" means logging them and immediately exiting.
|
# ? Dec 2, 2012 02:05 |
|
Sedro posted:Handle exceptions as appropriate when the exception is recoverable and expected. It's fine to handle exceptions in the main, so long as "handling" means logging them and immediately exiting. Yeah, I think that many times Pokemon exception handling gets made fun of it's not clear that the horror isn't catch (Exception), it's the fact that there's nothing in the catch block itself.
|
# ? Dec 2, 2012 09:53 |
GrumpyDoctor posted:Yeah, I think that many times Pokemon exception handling gets made fun of it's not clear that the horror isn't catch (Exception), it's the fact that there's nothing in the catch block itself. Those really are separate horrors, I'd say. Catching all is wrong because you don't know what you will end up catching and thus might never see serious problems, while doing nothing on an exception is just shutting your ears pretending the world (and yourself) to be perfect. So let's call them Pokemon EH and Iraqi EH. I just can't think of a good name for the combination.
|
|
# ? Dec 2, 2012 10:08 |
|
Sometimes bad code throws exceptions where the only response you could possibly have is "so what? who cares". Sometimes that same bad code throws exceptions for stupid poo poo and you just don't care about anything other than keeping your own code running continuously. The first case leaves you with either catch (SpecificException) { pass; } because the alternative is logging something you literally don't give any fucks about, and the second case leaves you either with catch (SpecificExceptions) { pass; } assuming you know every stupid exception the code can throw, or catch (Exception) { pass; } if literally no exception that code can throw is of any consequence to you and you just can't be bothered determining what specific exceptions are going to be thrown beforehand. It's not something you're likely to come across in good code when you're dealing with current, in-house projects, but good lord it comes up way too often when you're dealing with legacy application/library support. I deal with manufacturing machinery from the late 80s and early 90s where the software for it is so flimsy that I spend 90% of my time just out loud saying "holy loving poo poo why are you even telling me about this aaaaAAAAAAA". edit; these are systems where if something legitimately breaks the machines stop running, and regardless of what exception is thrown the original software just restarted the process to try again anyway. The Gripper fucked around with this message at 11:57 on Dec 2, 2012 |
# ? Dec 2, 2012 11:44 |
|
Catching all exceptions in Main is fine for production releases, since in the event of a fatal error you can display a pretty error message with an appropriate amount of information rather than whatever normally happens (like a generic .NET exception message followed by an illegal operation), plus you can generate an error report that can be sent in. Catching all exceptions anywhere other than Main is really dumb though.
|
# ? Dec 2, 2012 12:40 |
|
Volte posted:Catching all exceptions anywhere other than Main is really dumb though. - a background thread or detached process which reports on its failure - a WCF service which encodes them into faults - a library component which needs to encapsulate failures of its own dependencies into a predictable exception type - auditing code which logs the exceptions then lets them continue up the call stack
|
# ? Dec 2, 2012 13:20 |
|
|
# ? May 16, 2024 12:21 |
Volte posted:
Well if, as The Gripper mentions above, have to deal with old, lovely code that throws anything and everything, then you may need to catch them all. But only around the calls to the old code!
|
|
# ? Dec 2, 2012 13:23 |