|
This one made me weep today:code:
code:
|
# ? Oct 8, 2011 02:34 |
|
|
# ? May 25, 2024 14:58 |
|
The horror is not disposing that enumerator.
|
# ? Oct 8, 2011 03:41 |
|
Aleksei Vasiliev posted:make a pull request that just requests the file be deleted Those are the best: "+ 426 additions, - 24,623 deletions" https://github.com/tomdale/everyjs.com/pull/26
|
# ? Oct 8, 2011 04:20 |
|
Sedro posted:The horror is not disposing that enumerator. Trust me, all of my disposables are in using blocks.
|
# ? Oct 8, 2011 05:04 |
|
I ran across this today.code:
That is some quality poo poo right there.
|
# ? Oct 8, 2011 05:22 |
|
Ithaqua posted:This one made me weep today: That's not a real horror IMO; just misguided. It's a good technique to use where errorList isn't backed by an array, and where you actually dispose the enumerator (as already mentioned). Of course, Enumerable.Any is way better than both of these implementations. :smuglinq:
|
# ? Oct 8, 2011 08:23 |
|
ninjeff posted:That's not a real horror IMO; just misguided. It's a good technique to use where errorList isn't backed by an array, and where you actually dispose the enumerator (as already mentioned). It's certainly better than foo.Count(), but the general contract of a property is that it functions like a field with a bit of extra functionality hooked up to it. If something provides a Count property of its own accord, you can take it as given that that is efficient to access. If it implements an interface that requires it to implement that property, then you can generally assume that it's doing the necessary caching/maintaining that value behind the scenes. If something is expensive to determine and the object doesn't cache that value, then it should be a retrieval method, not a property.
|
# ? Oct 8, 2011 08:36 |
|
Jabor posted:It's certainly better than foo.Count(), but the general contract of a property is that it functions like a field with a bit of extra functionality hooked up to it. I agree, but the code posted was a method. edit: maybe that's the real horror ninjeff fucked around with this message at 08:53 on Oct 8, 2011 |
# ? Oct 8, 2011 08:50 |
|
Jabor posted:It's certainly better than foo.Count(), but the general contract of a property is that it functions like a field with a bit of extra functionality hooked up to it. In that particular case, errorList had a Count property. There was another instance that did the same thing but was IEnumerable, which I replaced with .Any(). ninjeff posted:I agree, but the code posted was a method. Most of this software is a horror. I'm improving what I can, when I can, without freaking the Crusty Old Dudes out. Sadly, during the interview process, I took the presence of Crusty Old Dudes to be a good sign. I hope that when I'm 60, some guy half my age isn't posting on SomethingTwitterBlogIpad.com making fun of me. New Yorp New Yorp fucked around with this message at 09:17 on Oct 8, 2011 |
# ? Oct 8, 2011 09:10 |
|
The real horror is that ICollection doesn't provide a way to tell if it's empty.
|
# ? Oct 8, 2011 10:37 |
|
Jabor posted:It's certainly better than foo.Count(), but the general contract of a property is that it functions like a field with a bit of extra functionality hooked up to it. I have to work on an application for which this isn't true, and it's a nightmare. Calling A.B.C.D.E.F is pretty commonplace, and each call always involves a SQL query and a home-made cache implementation (which never, ever removes anything from its cache). Here's what happens when you call a property on an object to get a related object:
Performing any operation on more than one base object at once takes minutes or hours thanks to this object model, and since the cache never throws anything out, ever, memory usage just keeps growing indefinitely until the application is closed. plushpuffin fucked around with this message at 19:22 on Oct 8, 2011 |
# ? Oct 8, 2011 18:15 |
|
plushpuffin posted:I have to work on an application for which this isn't true, and it's a nightmare. Calling A.B.C.D.E.F is pretty commonplace, and each call always involves a SQL query and a home-made cache implementation (which never, ever removes anything from its cache). Whoa you mean a code horror is in fact a code horror, you don't say? (ps ActiveRecord supremacy:) code:
|
# ? Oct 8, 2011 19:49 |
|
Zombywuf posted:The real horror is that ICollection doesn't provide a way to tell if it's empty. !IEnumerable.Any() seems to work well enough?
|
# ? Oct 8, 2011 21:40 |
|
Implementing ICollection implies that Count and Any() AKA GetEnumerator().HasNext() are both trivial operations so it doesn't really matter what you do. IEnumerable doesn't guarantee that the first item has been fetched so Any() might be nontrivial but you have no other choice. You could ensure that Count is called even on an upcasted ICollection like Microsoft does with Count()...code:
|
# ? Oct 8, 2011 22:49 |
|
Sedro posted:
Why is there a check for if the source is ICollection<T> when you just try treating it as an ICollection next?
|
# ? Oct 8, 2011 22:53 |
|
Because ICollection<T> doesn't implement ICollection
|
# ? Oct 8, 2011 23:35 |
|
i guess you're saying you want type erasure?
|
# ? Oct 9, 2011 01:10 |
|
Sedro posted:Because ICollection<T> doesn't implement ICollection ICollection<T> can't even be cast to a ICollection?
|
# ? Oct 9, 2011 01:16 |
|
tef posted:i guess you're saying you want type erasure? I want duck typing
|
# ? Oct 9, 2011 01:19 |
|
BonzoESC posted:ICollection<T> can't even be cast to a ICollection? MSDN posted:public interface ICollection<T> : IEnumerable<T>, So no. Sedro posted:
My single favorite thing about programming in Objective-C is that things like [myArray count] will return 0 whether myArray is null or empty. 99% of the time I want to know if the list contains something, and whether it exists and is empty or does not exist at all is irrelevant, but pretty much every other C-style language makes you spell it out every time.
|
# ? Oct 9, 2011 03:11 |
|
You don't have to throw in an extension method but it can be a little awkward because people expect an instance method (or what appears to be an instance method) to throw when called on a null value.code:
code:
|
# ? Oct 9, 2011 03:57 |
|
Sedro posted:Null is the real horror. please please please non-nullable reference types in the next windows platform M$
|
# ? Oct 9, 2011 09:28 |
|
Sedro posted:You don't have to throw in an extension method but it can be a little awkward because people expect an instance method (or what appears to be an instance method) to throw when called on a null value. Oh hey! I knew that throwing exceptions on null this in extensions was optional, and I'd started considering taking advantage of that, but it hadn't yet occurred to me to allow chaining by returning a default value. Looks like I'm gonna be refactoring some code this weekend!
|
# ? Oct 9, 2011 21:25 |
|
https://code.google.com/p/phpreboot/ Surely this is some brilliant troll?
|
# ? Oct 9, 2011 21:42 |
Xenogenesis posted:https://code.google.com/p/phpreboot/ "It has keywords such as if and elseif just like PHP, so therefore it is pretty much the same as PHP." It's written in Java. Sure, it may be interesting in its own right, it doesn't look like a terrible idea, but it has those two major faults. E: Hey you know, they should call it PHPScript. It's related to PHP the same way JavaScript is related to Java.
|
|
# ? Oct 9, 2011 21:55 |
|
It's like they deliberately took the worst parts of Javascript as well - automatic semicolon insertion? Seriously?
|
# ? Oct 9, 2011 22:13 |
|
They should just take the "don't need semicolons" thing from python instead of javascript.
|
# ? Oct 9, 2011 22:38 |
|
Vanadium posted:They should just take the "don't need semicolons" thing from python instead of javascript. Forced fixed indentation mixed with php would be so much fun since you can interleave html with php. Maybe mix some tapestry in there for good luck. code:
|
# ? Oct 9, 2011 23:17 |
|
Xenogenesis posted:https://code.google.com/p/phpreboot/ I think this is cool
|
# ? Oct 10, 2011 00:26 |
|
baquerd posted:Forced fixed indentation mixed with php would be so much fun since you can interleave html with php.
|
# ? Oct 10, 2011 01:01 |
|
While a good effort it will never, ever catch on. A long time PHP programmer's response is still 'gently caress it, just echo html back out to the page" even in frameworks that do everything they can to discourage that poo poo. I still see that poo poo suggested when working with say, drupal, where there's a clearly defined rendering path at the end of the processing chain, people seriously suggest just vomiting html straight to the page in the middle of processing functions. Ergh.
|
# ? Oct 10, 2011 01:12 |
|
I think my favorite part is how curly braces are used both for control flow and for delimiting code from HTML. Also raw XPath and URIs, both of which contain the end-of-line comment token
|
# ? Oct 10, 2011 01:16 |
|
Plorkyeran posted:no semicolons and semantically significant indentation have nothing to do with each other Right, my example was just running with the python mention.
|
# ? Oct 10, 2011 01:17 |
yaoi prophet posted:I think my favorite part is how curly braces are used both for control flow and for delimiting code from HTML. Also raw XPath and URIs, both of which contain the end-of-line comment token Well the first thing is no better in JSP, they also have XML-ish tags for serverside processing that seem to be able to live just fine inside non-XML, as far as I know. They also have some curly brace function/data insertion syntax thing. (And then there's the three different processing instruction tags.) In summary, JSP has three kinds of special tags, one of which has yet three sub-categories. I really don't see how an URI should be a syntax element of its own, and not just use string literals. It can't be a good idea to put them directly in the code anyway, that kind of stuff IMO falls under configuration.
|
|
# ? Oct 10, 2011 01:33 |
|
Jabor posted:It's like they deliberately took the worst parts of Javascript as well - automatic semicolon insertion? Seriously? Is there a significant difference between "automatic semicolon insertion" and "optional semicolons"? I can't see one, but the former seems to be reviled whereas most people seem to either not care about the latter or consider it a good thing.
|
# ? Oct 10, 2011 04:11 |
|
In Javascriptcode:
code:
|
# ? Oct 10, 2011 04:16 |
|
It gets even better!code:
Or the one that always gets people: code:
|
# ? Oct 10, 2011 04:44 |
|
Oh. So "automatic semicolon insertion" is "a semicolon is inserted at each newline if one is not already present".
|
# ? Oct 10, 2011 04:46 |
|
yaoi prophet posted:In Javascript gently caress everything about that. That and the weird requirement to use embracing style of braces, even though it's technically legal syntax to use the Allman style. I can deal with non Algol like languages like Python or god forbid VB, but gently caress JavaScript in its rear end for that one.
|
# ? Oct 10, 2011 04:47 |
|
|
# ? May 25, 2024 14:58 |
|
ToxicFrog posted:Oh. So "automatic semicolon insertion" is "a semicolon is inserted at each newline if one is not already present".
|
# ? Oct 10, 2011 04:59 |