I haven't slept well lastnight (only 4 hours) so please bear with me... but what is the joke on this snippet? "I Don’t Know".ToJson(); public string ToJson() { var s = new StringBuilder("{"); for (var i = 0; i
I assume item itself is missing, so nothing to convert... My guess
Shit programmers write
51–60 of 82 posts
Re: Shit programmers write
#52Re: Shit programmers write
#53I haven't slept well lastnight (only 4 hours) so please bear with me... but what is the joke on this snippet? "I Don’t Know".ToJson(); public string ToJson() { var s = new StringBuilder("{"); for (var i = 0; i
Re: Shit programmers write
#54I haven't slept well lastnight (only 4 hours) so please bear with me... but what is the joke on this snippet? "I Don’t Know".ToJson(); public string ToJson() { var s = new StringBuilder("{"); for (var i = 0; i
Re: Shit programmers write
#55I haven't slept well lastnight (only 4 hours) so please bear with me... but what is the joke on this snippet? "I Don’t Know".ToJson(); public string ToJson() { var s = new StringBuilder("{"); for (var i = 0; i
There aren't any obvious structural errors but two things occur to me. Firstly, JSON serialization is something every platform, including .NET, already has a multitude of libraries available for so this is 'reinventing the wheel' a bit. Secondly, looking at what it's actually doing, it's plausible the author doesn't even need JSON, as it's simply serializing a list of `id:name` fields. Thirdly, there are plenty of mo…
Re: Shit programmers write
#56> if (Session["startDate"] + "" == "") This feels horribly familiar. I'm not sure to recognize the specific language used, but there must be cases where one would like to target empty of filled with non processable characters strings only, and let null and falsy values pass through. This kind of use would typically need a line of comment, but hey...
Do this in javascript all the time. Adding a `+ ""` forces the object to become a string. Though not sure why it was required for this particular comparison.
Re: Shit programmers write
#57Earlier quoted context omitted.
From my experience, such code is not specific to MS technologies, but is indeed often found in “enterprisey” code, a lot of which just happens to be in Java and C#. And enterprisey code is like that because it's often outsourced to the lowest bidder. I once had to print a method that took 50 pages of paper, so I could understand what it does, and after 15 minutes I realized it's the same 60 lines repeated over and ov…
Just curious: Why does printing it on paper helps you to understand code better than reading it on screen?
Re: Shit programmers write
#58I haven't slept well lastnight (only 4 hours) so please bear with me... but what is the joke on this snippet? "I Don’t Know".ToJson(); public string ToJson() { var s = new StringBuilder("{"); for (var i = 0; i
I notice that the two pieces of data actually going into the JSON are "CustomFieldOptionId" and "OptionName" -- which seem somewhat useless/obscure, but there could be a legitimate reason for that.
So yeah, I don't quite get it either. Most of the others are more obviously silly.
Re: Shit programmers write
#59Earlier quoted context omitted.
Maybe this is a programmer who likes to spell things out for future readers. It's easier to convey meaning with return foo == null ? true : false;
Let's picture a future reader: "Hmmm, if 'foo == null' is true, than it's true... I see..." Seriously..
Re: Shit programmers write
#60I haven't slept well lastnight (only 4 hours) so please bear with me... but what is the joke on this snippet? "I Don’t Know".ToJson(); public string ToJson() { var s = new StringBuilder("{"); for (var i = 0; i
I assume item itself is missing, so nothing to convert... My guess
var item = CustomField.CustomFieldOption[i];
Shouldn't that be the item to convert? This looks like something stuck onto a class to serialize to JSON.I might be missing the joke also :(