|
nebby posted:For the record, say what you will about "bln_flg_tst_cnd_args_x", but I still think calling a return value "ret" or "result" is the goddamn stupidest idea I saw posted in all of those trainwrecks of threads I started. nebby posted:Cl<S,T> indicates a Java closure (which is just a anonymous class meeting one of the interfaces below) mapping from type S to T.. Clp<T> is a predicate closure (T => boolean), Clv<T> is (T => void) and Clvv is double void closure (void => void). "Predicate<T>" seems a better name than "Clp<T>" (it is, after all, the name being used for its addition to Java in the next version), for what it's worth. Also, Clvv is java.lang.Runnable except less self-documenting. Also also if Runnable is useful to you, java.util.concurrent.Callable<T> probably will be too, which is a combination you missed. nebby posted:Bring on the hate, but I'd love to see your examples of functional constructs in java that don't read like a goddamn essay. On the other hand that kind of construct is definitely handy, which is why it's been implemented so many times in the past, and presumably why people seem to be finally integrating it into Java's libraries themselves. I'm not sure how I feel about closures in Java in general, though – Josh Bloch makes a good case showing the complexity they add to the language while removing readability, since there's been little actual consultation on the current BGGL Closures proposal. The proposal may well go through, though. I don't know BGGL closures but with Scala (another JVM language), your last code example would look like this: code:
zootm fucked around with this message at 15:53 on Mar 29, 2008 |
# ¿ Mar 29, 2008 15:33 |
|
|
# ¿ Apr 29, 2024 07:39 |
|
nebby posted:For example, if you are writing a method called countOfApplesInBasket() that returns a count of apples, if I see the line "result += 1;" I have to look at context to determine wtf result is. In this case, it's a count of apples. It's much nicer to just call it something like "countApples", it doesn't require context and gives the variable a much more meaningful name. The "but you can always look at context" defense is what I got a lot of in my old threads but it's entirely missing the point because the overall goal of naming itself is to minimize the amount of unnecessary cross referencing of context by the programmer. nebby posted:The fact that it is the value being returned (and the fact that the concept of "return values" exists in my language) shouldn't impact the name of my variables in a method written against a certain domain like apple counting. I'd argue that the vast majority of the time there is a better name than "result" or "x" or "i". nebby posted:And yeah, I realize "Runnable" and "Predicate" (and in .NET "Action") exist but my main issue is that when you are talking about something as fundamental as closures (or 'functors' as you put it, but Java anonymous inner classes pseudo-capture final variables and this variables so I think they are closures) that every extra bit of verbiage hurts and learning a few acronyms basically gets the ugly syntax out of the way so you can avoid reading it altogether. You'll note I just throw all the anonymous inner class declaration crap on the end of the line even though that's not canonical Java formatting. Also, in this case "closure" isn't even what the objects are. "Closure" (or "anonymous inner class") is the language feature that you use to generate them. The actual objects are functors, or function objects, or just functions, or whatever you want to call them. nebby posted:And yeah, I like Scala from what I've read so far, but time constraints are keeping me from trying to get my Android app running on Scala (which actually works, supposedly.) I'll do it eventually though nebby posted:Edit: Here's the same code with 'common sense' applied. It's probably more intuitive to most of the readers of this forum, but it feels like a sack of molasses to me, it turns what should be a one-liner in any sane language into an abomination.
|
# ¿ Mar 29, 2008 18:05 |
|
tef posted:If we're going into unicode territory how about something like ∀ x ∈ l : print x; perhaps?
|
# ¿ Mar 31, 2008 17:28 |
|
chocojosh posted:I sometimes put the return expression in parenthesis simply because I find it more readable. Is that really a coding horror?
|
# ¿ Apr 3, 2008 20:22 |
|
chocojosh posted:The latter. Note that I don't think I've ever done return (retVal); but I will do things like return (x + 10); or return (x > 0)
|
# ¿ Apr 3, 2008 22:02 |
|
I think either some spacing or avoiding the ternary operation altogether would make the "after" code in that example a lot easier to read, JingleBells. I realise that readability wasn't the "horror" in the original, though.
|
# ¿ Apr 10, 2008 14:20 |
|
Caching the prime numbers is memory-intensive. For the best performance profile you should calculate them on-demand each time.
|
# ¿ Apr 24, 2008 20:06 |
|
The great thing about the prime factorisation solution is that you can have counted flags. It's like the flag equivalent of turning your amp up to 11.
|
# ¿ Apr 25, 2008 13:42 |
|
Setting someone as logged in just because they passed a filename in the query parameter seems to me to be the horror here.
|
# ¿ May 10, 2008 00:53 |
|
TheSleeper posted:Well they obviously are quite a bit worse off since taking the uninitialized data out as a source of entropy apparently led to weak keys.
|
# ¿ May 14, 2008 21:03 |
|
CT2049 posted:The only thing I can think is that then you can glance and easly see if your checking for the true case or the false case, but even that is so simple the == shouldn't be necessary.
|
# ¿ May 15, 2008 23:09 |
|
TSDK posted:No it wouldn't.
|
# ¿ May 16, 2008 10:44 |
|
Zakalwe posted:break my_label is no different than goto my_label as far as breaking out of loops is concerned. It just removes the functionality of one "evil" and sticks it in another.
|
# ¿ Jun 15, 2008 14:42 |
|
Standish posted:Because it's needlessly verbose and also because "some_variable" can evaluate to true while "some_variable == true" evaluates to false e.g. TRex EaterofCars posted:It's just the way languages like C handle their if statements. Java specifically decided to not allow it to work that way because of the specter of "ambiguity". zootm fucked around with this message at 22:07 on Jun 20, 2008 |
# ¿ Jun 20, 2008 22:04 |
|
I remember catching this one time in production C# code at an old job:code:
|
# ¿ Jul 8, 2008 19:34 |
|
In most Java debuggers, and I suspect in VS by now, you can set the system to break on exception. In any case I imagine putting at least a throw; in there would be preferable for when you forget to remove the code, so the semantics don't change.
|
# ¿ Jul 8, 2008 22:01 |
|
RoadCrewWorker posted:Still, how would declaring a block variable that gets lost after the catch{} is done change the semantics of the program? It really is best to avoid munging your program at all to make it "easier to debug"; this sort of thing can be too easy to leave in to a stage where it's more expensive to find and fix. Volte posted:Can't you just put the breakpoint on the closing brace?
|
# ¿ Jul 8, 2008 22:55 |
|
OneEightHundred posted:I'm still trying to find this. Edit: I lie, Google apparently knows about these things. See under Breaking on Exceptions on this page. Volte posted:Well it works in Eclipse with MinGW/GDB. zootm fucked around with this message at 23:21 on Jul 8, 2008 |
# ¿ Jul 8, 2008 23:19 |
|
JediGandalf posted:Why put it on the brace when you can put it on the catch statement itself?
|
# ¿ Jul 10, 2008 09:34 |
|
Sebastian Flyte posted:Exactly. Doing a transaction with a single SQL command deleting one single row is pretty pointless.
|
# ¿ Jul 11, 2008 11:57 |
|
Ryouga Inverse posted:I was quite aggravated about this. No exceptions, nothing. I wish I could find the code again.
|
# ¿ Aug 29, 2008 13:52 |
|
Mustach posted:== and != are overloaded to do value comparison for Strings in C#.
|
# ¿ Aug 29, 2008 19:32 |
|
I think a lot of languages do it that way, actually. Certainly Ruby does as well. Doesn't seem like something that scales well to multiple threads (insert Ruby gag here) but it certainly seems pretty consistent with the way the language works, especially given that Exceptions are the best way to break normal control flow in exceptional cases. Edit: It might be possible to override the default interrupt handler in these languages actually. Edit 2: Yeah, Signal appears to let you override the default behaviour in Ruby, there's likely to be something analogous for Python. This makes the default behaviour seem more sensible. Edit 3: And it's signal in Python. This seems like the best compromise where ctrl-C has a nice default behaviour that you can override. zootm fucked around with this message at 18:04 on Nov 5, 2008 |
# ¿ Nov 5, 2008 17:53 |
|
Zombywuf posted:I wouldn't let exceptions escape signal handlers. Zombywuf posted:I certainly wouldn't define keyboard interrupt as an exception.
|
# ¿ Nov 6, 2008 23:47 |
|
Zombywuf posted:It only provides expected behavior in the case where you're trying to catch KeyboardInterrupt. When you're expecting the semantics of exceptions to mean "something has gone wrong with the code in my try block", the behavior will break your program. zootm fucked around with this message at 01:23 on Nov 7, 2008 |
# ¿ Nov 7, 2008 01:21 |
|
Factor Mystic posted:
Edit: Holy poo poo, it is. That'll teach me to joke about such things. zootm fucked around with this message at 14:26 on Jan 1, 2009 |
# ¿ Jan 1, 2009 13:57 |
|
Good lord. Although relational databases are terrible for scaling, this does sound as though it's the worst possible way around that.
|
# ¿ Jan 5, 2009 14:45 |
|
thesaddestpirate posted:
|
# ¿ May 12, 2009 20:15 |
|
tef posted:this for new cobol title
|
# ¿ Jun 9, 2009 13:48 |
|
Parantumaton posted:Java's String#replaceAll(String, String) is regex based which means there's the overhead of generating internal Pattern object for the actual regex, creating a Matcher object from the said Pattern object and then calling Matcher#replaceAll(String) to get the output. If all you need is simple replacement ("change all 'a':s to 'b':s") which is going to get used a lot in your application then rolling out your own #replaceAll() will actually result in a lot faster throughput than the Java's native regex one. Same applies especially to Pattern#split(String) too. This is all potentially well and good but just look at the code they're using - there's no way it's an optimisation.
|
# ¿ Sep 5, 2009 10:09 |
|
Zombywuf posted:If you think that: Also Actor/Agent/Process model is basically just asynchronous object-orientation. Message-passing actors are a really nice way of building but sometimes people act as though they're some kind of magic cure-all when they're not really all that different to how large systems were already engineered. Erlang's "big win" is nicely codifying and implementing the frameworks you need to get this sort of thing off the ground. Don't know where I'm going with this. In any case these arguments seem secondary to the stated goal of coding horrors. Edit: ColdPie posted:Should've known the 65 new posts weren't 65 new funny posts but instead 65 new posts arguing about functional programming.
|
# ¿ Nov 30, 2009 16:57 |
|
Zombywuf posted:And one post whinging about people arguing about functional programming.
|
# ¿ Nov 30, 2009 17:00 |
|
MononcQc posted:This kind of stuff was used in every god drat library file we had because at some point in history the site would have some kind of common library directory with a bunch of other sites we had on a single server. Said websites would sometimes call files coming from each other to allow some weird interactions. Zombywuf posted:The only places I've seen anything similar are server/daemon monitoring tools. Erlang is the only place I've seen it as part of the language, this is another area where Erlang seems to be trying to subsume the UNIX philosophy.
|
# ¿ Nov 30, 2009 18:49 |
|
It's probably intended to get as far as the database at which point it'll fail because "WTF" isn't a valid data type. Still a horror, though. I like the "MONEY" type as well although I suppose that'll be a real uninteresting decimal type.
|
# ¿ Dec 4, 2009 00:28 |
|
yaoi prophet posted:I seem to recall the MONEY type being specially designed to avoid that sort of stuff, but I'm not 100% certain
|
# ¿ Dec 4, 2009 13:07 |
|
megalodong posted:A novel implementation of str_replace(" ", "", $str):
|
# ¿ Dec 22, 2009 16:26 |
|
Mustach posted:"And in the end, the love you take is equal to the love you pass by value." — John Lennon code:
|
# ¿ Dec 30, 2009 14:02 |
|
MrMoo posted:Not enough! Say hello to NIO.2.
|
# ¿ Jan 31, 2010 13:11 |
|
Edit: Replied to Zombywuf without realising.
|
# ¿ Feb 9, 2010 14:28 |
|
|
# ¿ Apr 29, 2024 07:39 |
|
TRex EaterofCars posted:Yup, that's the web application servlet context and request being passed in. To a job. That runs via Quartz.
|
# ¿ Sep 23, 2010 12:48 |