|
Smackbilly posted:haha oh god... at least that gets creativity points. Who needs RTTI when you have exceptions? On the subject, I got to extend a code base for a student project that did stuff like this: code:
*Class functions would throw exceptions on completion (or error) to be caught by other class functions. There were also a few places where whoever wrote it clearly could have used a switch if it had occurred to him.
|
# ¿ Jun 18, 2008 23:32 |
|
|
# ¿ May 7, 2024 17:35 |
|
more falafel please posted:Exceptions are like goto, only they're just "gosomewhere". Plus they're objects and can carry a payload of other objects. It's the perfect fusion of functional and object oriented 'features' in one disturbing package.
|
# ¿ Jun 20, 2008 17:26 |
|
Sivart13 posted:I get the feeling even posting the best-written COBOL you could find would still be valid for this thread. Actually, if this: code:
|
# ¿ Aug 27, 2008 14:49 |
|
ashgromnies posted:Wouldn't that kill the English readability of something like: I was thinking a shorthand just for this case: code:
|
# ¿ Aug 27, 2008 16:55 |
|
Volte posted:Well some languages like Python have an 'in' operator. Like I know, but I was specifically thinking of C-style languages where ==[] might look more at home in a conditional. Also, JavaScript and C# already use in for other things.
|
# ¿ Aug 27, 2008 17:15 |
|
Damnit, guys. Quit bringing practical solutions to my fantasy land.No Safe Word posted:Monkeypatching FTL. I don't know that it counts as monkeypatching but I still like it less than adding some shorthand to the language. And where the hell is your avatar from?
|
# ¿ Aug 27, 2008 17:55 |
|
No Safe Word posted:Hacking into a class that you didn't create is, in my mind, monkeypatching. Whether it's tacking on a method or redefining an existing one. The super official Wikipedia definition says it has to happen at run time which may or may not be the case depending on how they do the magic in the IL. At any rate, wouldn't that method show up in CodeSense and be type cheched at compile time, making it signifigantly safer and more visible than the traditional monkeypatch? quote:edit: Thanks, now I'll ahve to go check it out.
|
# ¿ Aug 27, 2008 18:11 |
|
Janin posted:If it's going to throw an exception anyway, why even use has_next()? That's a lot like saying 'If the program is going to exit when it crashes, why bother trying to fail gracefully?' If you design your generator to make a mess then it will make a mess. Congratulations on restating the garbage in garbage out principal again. It just doesn't make a lot of sense to use what most people would consider/assume to be specialized error handling machinery for flow of control or event notification. Not that you can't, but don't expect the rest of the world to agree that it's a perfect system and a great idea.
|
# ¿ Nov 7, 2008 20:51 |
|
Janin posted:The generator is not "making a mess". Many generators have side effects, and it's important that the side effects happen at the prescribed time. I inserted the sys.exit() to prevent arguments about pre-caching results; often, the results themselves are unimportant and it's the side-effects of the generator that matter. I would say that exiting any serious program from (essentially) inside a loop conditional is making a mess. That's getting into serious WTF territory unless you're just doing it to screw with someone. quote:The issue with using a has_next()/get_next() style is that it's not as general as the current system. Any loop implemented with has/get_next() can be wrapped in a generator, but the converse is not true because the behavior of a generator allows unpredictable results. I think it would make some sense to force people to use a generator that can have side effects differently than one that can't in most cases, but that could easily be my newness to Python talking. quote:I don't think anybody is arguing that it's perfect, but it's certainly better than the alternatives. People just need to get over the "all exceptions are errors" mentality. Then maybe it should be called an event, rather than an exception(al circumstance)? We could just call all numbers ints, since we're rewriting common paradigms. Some ints will just happen to have decimals.
|
# ¿ Nov 7, 2008 21:39 |
|
Janin posted:Or you could just use exceptions. Obviously you've learned, or been taught, that exceptional circumstances are inherently errors. In Python, this is not the case; an exception just means that the code was unable to finish executing, for any reason. It does look an awful lot like Guido shoehorned what would be an event anywhere else into the exception model because, in the context of every other language I have used, this is strange behavior. Conditions already look like a better idea just because they don't try to call a shoe a sock. Munkeymon fucked around with this message at 22:21 on Nov 7, 2008 |
# ¿ Nov 7, 2008 22:19 |
|
Janin posted:What languages have you used? If you've only used the C family (C++/C#/Java) then the idea of a non-error exception will seem strange, but to understand Python you need to realize that they are different concepts. It's often a good idea to give different concepts different names - and possibly even different structure - to avoid confusion. When you borrow the name and structure for a construct like exceptions from the popular language crowd and then subtly change what it's generally used for, you create a situation where problems are more likely for most programmers who use your language. I could also see a Python-taught programmer bringing this concept to a different language and making a huge mess. Anyway, it's silly to argue over this now since it's not going to go back in time and affect Guido's decision, but I think he screwed up there. Not a huge deal, but still not the best idea he's had.
|
# ¿ Nov 8, 2008 00:12 |
|
geetee posted:
What, you don't think they should test the live production flag
|
# ¿ Nov 19, 2008 18:49 |
|
TSDK posted:... and why is a function for reading called 'write' at one point? It's obviously writing the file to the buffer you big noob ugh it's like you've never seen real code before There's probably a write(StringBuffer con,StringBuilder fle) that writes the buffer back to the file ymgve posted:To elaborate more on my question, which of these are good/bad? I like the third and first ones (in that order), myself.
|
# ¿ Nov 20, 2008 20:25 |
|
ymgve posted:I've always felt the third one is a bit iffy because you have the same call twice, so if you ever change the code around, you have two locations that you need to change. Not so hard in this simple example, though. True, but how often would you expect a read call to change form in a signifigant way? Did you recently change your username?
|
# ¿ Nov 20, 2008 21:08 |
|
ymgve posted:Nope, same username since registration. Why? Memory corruption on my part, I guess. I mostly remember avatars, anyway. Ryouga Inverse posted:I think I want to kill myself. Just kill the guy who turned that poo poo in and maybe his job could be filled by someone who doesn't leave the # out of C#.
|
# ¿ Nov 21, 2008 23:46 |
|
Jethro posted:I think he's programing C♭ instead. I'm not musical enough to know what the hell that thing is
|
# ¿ Nov 21, 2008 23:56 |
|
php:<? if(strpos($userid,".")>=0)$userid=-5; ?> Me, 1 hour later: gently caress! Now I'm searching our entire codebase for more cases of PHP programmers not understanding PHP. Obligatory: PHP is a coding horror
|
# ¿ Jan 28, 2009 23:38 |
|
Sartak posted:Even still, why would you subtract 5 from the userid if it contains a period? The userid is supposed to be coming from a 3rd party authentication system and apparently there were periods getting in there somehow (and probably causing database errors) from someone at some point in the last 5 years. Rather than force people writing code upstream of the core authentication system to deal with it properly, someone decided it would be a great idea to hide a line in the system that will gently caress the userid right in the ear in this one specific case and then went and did it in a profoundly stupid way. I could post a bunch of our codebase in this thread but I'm extra pissed about this one because I read over this line 4 or 5 times before it occurred to me why it was wrong. It's supposed to set the userid to -5, by the way (it's = -5 not -= 5).
|
# ¿ Jan 29, 2009 15:56 |
|
More!php:<? $today = getdate(); $todayDate = sprintf("%04d%02d%02d_%02d%02d%02d", $today['year'], $today['mon'], $today['mday'], $today['hours'], $today['minutes'], $today['seconds']); $todayDate = $todayDate ^ "pippopippopippo"; $toret = $userid . "." . $todayDate; ?>
|
# ¿ Feb 4, 2009 22:03 |
|
Mill Town posted:Apparently XOR is defined on strings in PHP. HAHAHahah haha hah ha Even better: the manual says the only operators that work on strings are . and .= http://us.php.net/manual/en/language.operators.string.php
|
# ¿ Feb 4, 2009 23:13 |
|
FeloniousDrunk posted:Seems to me all of that above could be written as: Yes and yes. It was changed at some point to the following (which doesn't deserve to be a full function if you ask me) php:<? $toret = md5($userid . "." . time()); return $toret; ?>
|
# ¿ Feb 5, 2009 15:43 |
|
Ugg boots posted:I know some people like that, but Ugg I hate it. I'd rather jump the hell out of a triply-nested loop with a Return statement than try to get out some other way. (Though I guess PHP has a break(x) function that breaks you out of multiple loops, doesn't it?) Yep, but I don't think I've seen it used anywhere I didn't put it in, and for the record, I also think single point of return is stupid. It has ceritanly caused or helped cause some ugly poo poo in our software.
|
# ¿ Feb 5, 2009 20:33 |
|
tripwire posted:There is no god but PERL and regular expressions are his prophets. Can't figure out whay that popped into my head - I certianly don't like PERL that much.
|
# ¿ Feb 12, 2009 15:42 |
|
Triple Tech posted:Perl. Perl. Do you go around saying poo poo like JAVA or RUBY? <> Do Java or Ruby stand for something? 'Cuz I'll start doing that if they do.
|
# ¿ Feb 12, 2009 17:31 |
|
6174 posted:If you're going to go for the false etymology, you might as well go for Pathologically Eclectic Rubbish Lister. Yeah, that's really a lot more accurate. Edit: Why the hell did he call it Perl if that didn't stand for something? Or did he just invent a language and then call it something? Munkeymon fucked around with this message at 18:55 on Feb 12, 2009 |
# ¿ Feb 12, 2009 18:28 |
|
Plorkyeran posted:Indeed, Wall claims that the name was intended to inspire many different expansions.[14] I swear that guy would be most happy living in the programmer's district of Toonland or whatever it was from Roger Rabbit. quote:What's your language today, Larry?
|
# ¿ Feb 12, 2009 22:57 |
|
Ugg boots posted:You really like the word frobnicate, don't you? At least it's something other than foo(bar).
|
# ¿ Apr 15, 2009 20:42 |
|
McGlockenshire posted:Much to our collective horror, the values are modifiable within the sort. I have no idea who thought this was a good idea, but I'm going to give him or her a piece of my mind should we ever meet. So, during the sort, the left value is always being modified. I'm not sure what method Perl uses internally to perform the sort, the results are the same every time on Perl 5.10.0. Wouldn't a pass-by-reference system be the best generic way to do it in Perl if you want people to be able to, say, sort an array of arrays by the lengths of the constituent arrays? Honest question - I'm not a Perl expert, I just tinker with it occasionally.
|
# ¿ Jun 16, 2009 15:03 |
|
Dijkstracula posted:Indeed, you need to pass by reference, but in your example (unless I'm misunderstanding your question) there's no need to allow the dereferenced array to be modifiable. Wouldn't that basically be creating a seperate and logically inconsistent state for the interpreter to be in while sorting? I'd say it's better to just let a few profoundly stupid/crazy people to shoot themselves in the foot than to create new potential interpreter bugs and certian work for some maintainer.
|
# ¿ Jun 16, 2009 17:44 |
|
BigRedDot posted:I work on sonar systems for submarines, I can say confidently that regular expressions are not at all an integral part of the programming we do. But what if you have to find an enemy submarine that resembles a well-formed propper name? What then Mr. Smarty-Pants?
|
# ¿ Aug 3, 2009 21:12 |
|
Otto Skorzeny posted:I was assuming that any taint feature in PHP would be a shittier and dumber cargo-cult-copy of its Perl analog (like every PHP feature) http://blog.php-security.org/archives/92-CORE-GRASP-PHP-Tainted-Mode.html welp
|
# ¿ Aug 31, 2009 16:16 |
|
Painless posted:Maybe someday someone will make the ultimate PHP security patch - a patch that causes PHP to remove itself from the server on first use.
|
# ¿ Sep 1, 2009 17:50 |
|
Flobbster posted:I don't know how good VB (compile) --> MSIL (decompile) --> C# would look It still looks pretty good except for a few small problems like certain features of VB causing implicit declarations that got (maybe still get?) turned into stuff like $12AB = something; that doesn't compile if you just paste it into a code file because of the $. I was in charge of obfuscating the build at the place I used to work and most obfuscaters I tried did a passable job of mangling the logic, but would usually gently caress up namespace resolution to produce code that crashed all over the place unless you excluded huge chunks of your project from obfuscation
|
# ¿ Oct 2, 2009 19:22 |
|
Nigglypuff posted:this is an irl job that people have I was in charge of making an obfuscated build because I was in charge of the build because I was in charge of continuous integration. Obfuscation wasn't supposed to be a big deal because you're just supposed to be able to point the product we were using at the assemblies and tell it to go nuts, but it took days of tweaking settings in the obfuscater to get the obfuscated assemblies to not crash on startup. I never did get a fully functional, obfuscated build made while I was there. No, it was not fun. I think the product was Object Blender or something? The SmartAssembly demo worked on the first try, but he had already bought the other piece of poo poo as a bundle with some pre-made Vista-like UI controls from the same company.
|
# ¿ Oct 2, 2009 21:00 |
|
Lonely Wolf posted:Well I hope this thread has taught you that it's far cheaper and far more effective to simply hire worse programmers. We did have a guy overloading different Collections classes so he could rename the access methods, so there's that. CollectionSubtype.count_mine() is clearly superior I think the real moral of the story is that you should buy your IL obfuscater from the same place you get your prebuilt UI widgets because saving a few hundred bucks is totally worth days of programmer time per release and you know those guys know their IL obfuscation because that ribbon widget is totally shiny as gently caress.
|
# ¿ Oct 5, 2009 20:19 |
|
Does this:php:<? if(is_numeric($extid)) $sql .= "us_extid=$extid"; else $sql .= "us_extid='".$extid."'"; ?> *that's a 6-digit number with a leading zero, fyi
|
# ¿ Nov 17, 2009 21:55 |
|
Sprawl posted:Can't you typer your variable before you put stuff into it? Strict typing would require about a week of work for rewriting and testing while this had to be done today. Also, I don't see how the behavior of == makes any difference to is_numeric, which quite clearly changed its behavior when acting on the same data as I tapped F5 a few times earlier today.
|
# ¿ Nov 18, 2009 00:12 |
|
Mill Town posted:DB DB DB... Th-th-th-that's all folks! I chuckled. I think us PHP users have to find humor where we can
|
# ¿ Dec 4, 2009 16:38 |
|
zootm posted:I knew a guy who did something near-identical to this (in Java) when I was at uni. I suggested the single-line version and he just kinda looked stunned, then said he'd "maybe think about doing it that way later". Oh, well. That was amateur horror. It takes professionals to create Live Horrors code:
|
# ¿ Jan 5, 2010 23:52 |
|
|
# ¿ May 7, 2024 17:35 |
|
Lonely Wolf posted:I want to quote my favorite line, but I just can't decide: they're all so bad. The person who wrote this is in an office in Europe, so that wouldn't even help. I would like to find a new job, though. Anyone in Minneapolis hiring? RussianManiac posted:I am pretty sure this is just somebody doing a horror on purpose. Hahahahahahaaaaaa no. Pretty sure this is the same guy: code:
code:
|
# ¿ Jan 6, 2010 15:18 |