|
logic
Last post 12-14-2012 10:34 PM by savar. 24 replies.
-
12-13-2012 9:39 AM
|
|
-
snoofle


- Joined on 06-22-2006
- Posts 1,422
|
Useful variable and function names shortened for readability (the if-part of this was all on a single line nearly 1,000 characters long):
if (a(!b(!c(d(e()[f()])).g(h(),i(),j(k()[2])))) > m(n(),o(),p(q().r()))) {...}
OBTW, e(), h() and q() are hierarchies that contain database hits.
Why oh why do people write code like this?
|
|
-
-
-
-
C-Octothorpe


- Joined on 03-07-2011
- Posts 798
|
Sutherlands: C-Octothorpe:
That looks like minified JS. Someone actually did this by-hand and intentionally?!
Well he specifically said he shortened the variables for readability...
Ah, parsing error on my part. I read it as the author of the code shortened the variables for "readability"...
|
|
-
-
The_Assimilator


- Joined on 05-23-2007
- South Africa aka HELL
- Posts 437
|
C-Octothorpe:That looks like minified JS. Someone actually did this by-hand and intentionally?!
JS that does DB calls? I don't think my mind can fully comprehend such horror.
<stryhf> why do people persist in continuing to write SHIT APPLICATIONS IN JAVA <stryhf> writing SHIT in JAVA doesn't make it ANY LESS SHITTY <stryhf> IT JUST MAKES IT SLOW ASS SHIT
|
|
-
-
emurphy


- Joined on 01-14-2005
- Granada Hills, CA
- Posts 568
|
"JS" only came into the conversation from the "minified JS?" comment; the code could just as easily be Java or one of the C family. Of course, this is a snoofle WTF, so JS doing a DB call isn't entirely implausible...
|
|
-
-
Lorne Kates


- Joined on 01-19-2010
- Markham, ON
- Posts 1,496
|
The_Assimilator: C-Octothorpe:That looks like minified JS. Someone actually did this by-hand and intentionally?!
JS that does DB calls? I don't think my mind can fully comprehend such horror. Not directly (as far as I know and hope), but you can do this: var a_returner = false; function a() { $.ajax({ url:"snooflecorp.com/WebService/GetDataBaseResultsForA.java", async: false, success: function() { a_returner = true; }, fail: function() { a_returner = false; } }); return a_returner; }
// Copy and paste for each other variable
That way not only do you have 26 database hits, but you also have 26 asynchronous web requests!
 <%= Eval("sig_owner") ?>! <asp:Label runat="server" id="lblGetYourOwn" Text="Get your own!" />
|
|
-
-
joe.edwards


- Joined on 08-14-2006
- Dallas, TX
- Posts 1,100
|
Lorne Kates:That way not only do you have 26 database hits, but you also have 26 asynchronous web requests!
Don't forget 26! = 403291461126605635584000000 possible orderings of return callbacks.
I spend most of my life pressing buttons to make the pattern of lights change however I want.
|
|
-
-
Anketam


- Joined on 10-12-2011
- Nar Shaddaa
- Posts 484
|
Good grief. Has this programmer not heard of using temporary variables?!
Project Manager: I don't know. I'm not allowed to talk directly to the customer. Apparently my grip on reality is too tight. - Weng
|
|
-
-
joe.edwards


- Joined on 08-14-2006
- Dallas, TX
- Posts 1,100
|
Anketam:Good grief. Has this programmer not heard of using temporary variables?!
Maybe he has a Lisp.
I spend most of my life pressing buttons to make the pattern of lights change however I want.
|
|
-
-
Adriano


- Joined on 04-24-2008
- Chile
- Posts 41
|
Lorne Kates:var a_returner = false; function a() { $.ajax({ url:"snooflecorp.com/WebService/GetDataBaseResultsForA.java", async: false, success: function() { a_returner = true; }, fail: function() { a_returner = false; } }); return a_returner; }
// Copy and paste for each other variable
That way not only do you have 26 database hits, but you also have 26 asynchronous web requests!
That "async: false," bit makes it a bit less asynchronous than you'd expect, I think.
Saludos Adriano
|
|
-
-
C-Octothorpe


- Joined on 03-07-2011
- Posts 798
|
The_Assimilator: C-Octothorpe:
That looks like minified JS. Someone actually did this by-hand and intentionally?!
JS that does DB calls? I don't think my mind can fully comprehend such horror.
I said it looks like minified JS, not that it is.
In any case, I've known developers who would think that a "one-liner" like this is elegant, or worse yet, that this saves memory because you're not creating local variables...
|
|
-
-
Rhywden


- Joined on 09-07-2010
- Posts 188
|
Adriano: Lorne Kates:var a_returner = false; function a() { $.ajax({ url:"snooflecorp.com/WebService/GetDataBaseResultsForA.java", async: false, success: function() { a_returner = true; }, fail: function() { a_returner = false; } }); return a_returner; }
// Copy and paste for each other variable
That way not only do you have 26 database hits, but you also have 26 asynchronous web requests!
That "async: false," bit makes it a bit less asynchronous than you'd expect, I think.
Well, if he expected to do such a long if-clause with asynchronous calls, then I honestly don't know what he expected!
|
|
-
-
-
Zylon


- Joined on 12-14-2006
- Posts 435
|
snoofle:Why oh why do people write code like this?
Because somebody made fun of them for writing code that was clear, but verbose.
|
|
-
-
Nexzus


- Joined on 09-11-2008
- Posts 105
|
Almost as bad as method/property chaining.
someobject.someProperty().someOtherProperty().yetAnotherMethod().andStillOneMore().andAFinalOneForShitsAndGiggles().toString().toLower().equals('...");
|
|
-
-
snoofle


- Joined on 06-22-2006
- Posts 1,422
|
@All: It's pure Java. The variable names were shortened by me for posting. The run time for this one "line" of code is, on average, approximately 94.7 seconds (yes, ninety four point seven seconds). True, the db hits are fairly reasonable for what they do, and the caching of the query results are side affects (seriously!) buried deep in the bowels of the system, but still, this could trivially have been broken down into something way more readable (I wound up breaking it down into a bunch of sequential statements, each making a single call).
|
|
-
-
Zecc


- Joined on 06-12-2007
- and hasn't left since.
- Posts 1,672
|
Adriano: Lorne Kates:var a_returner = false; function a() { $.ajax({ url:"snooflecorp.com/WebService/GetDataBaseResultsForA.java", async: false, success: function() { a_returner = true; }, fail: function() { a_returner = false; } }); return a_returner; }
// Copy and paste for each other variable
That way not only do you have 26 database hits, but you also have 26 asynchronous web requests!
That "async: false," bit makes it a bit less asynchronous than you'd expect, I think.
It allows returning a meaningful a_returner though.
If mixed metaphors were illegal, I'd be having an indigestion. typeof NaN == 'number' var ò_ó, ಠ⁔ಠ, ᄒᆺᄒ, ᅙᅳᅙ, ᖛᨓᖜ, ꖴᅩꖴ, ఠᨋఠ; // Naming your variables is serious business
|
|
-
-
Mcoder


- Joined on 01-06-2007
- Posts 208
|
Adriano:That "async: false," bit makes it a bit less asynchronous than you'd expect, I think. It makes is synchronous enough for this small function become thread safe. There can still be 26 requests running at the same time, with the number of possible execution orderings calculated by joe.edwards. Also, thank god browser tabs are single threaded. Otherwise you'd at least double the possible execution orderings.
|
|
-
-
flabdablet


- Joined on 04-09-2011
- Posts 445
|
snoofle:Useful variable and function names shortened for readability (the if-part of this was all on a single line nearly 1,000 characters long):
if (a(!b(!c(d(e()[f()])).g(h(),i(),j(k()[2])))) > m(n(),o(),p(q().r()))) {...}
OBTW, e(), h() and q() are hierarchies that contain database hits.
Why oh why do people write code like this?
I don't think code like that is ever really so much written as grown. It's organic, like toe jam.
|
|
-
-
PSWorx


- Joined on 04-28-2006
- Posts 1,290
|
Lorne Kates:var a_returner = false; function a(sql) { $.ajax({ url:"www.snooflecorp.com/WebService/QueryDatabase?sql=" + sql, async: false, success: function(data) { a_returner = data; }, fail: function() { a_returner = null; } }); return a_returner; }
That way not only do you have 26 database hits, but you also have 26 asynchronous web requests!
FTFY. Do you think the masterminds at SnoofleCorp would tolerate copy-pasting if you can make it generic?
|
|
-
-
fire2k


- Joined on 06-02-2010
- Posts 60
|
Lorne Kates: The_Assimilator: C-Octothorpe:That looks like minified JS. Someone actually did this by-hand and intentionally?!
JS that does DB calls? I don't think my mind can fully comprehend such horror. Not directly (as far as I know and hope), but you can do this: Ever heard of Node.js? Sure, your code needs a webserver in some form, but since you are running a DB-server anyway...
|
|
-
-
Zecc


- Joined on 06-12-2007
- and hasn't left since.
- Posts 1,672
|
fire2k:Ever heard of Node.js? Sure, your code needs a webserver in some form, but since you are running a DB-server anyway...
You don't need Node.js, a web server or a database server. All you need is a standalone JS implementation with a sqlite binding.
If mixed metaphors were illegal, I'd be having an indigestion. typeof NaN == 'number' var ò_ó, ಠ⁔ಠ, ᄒᆺᄒ, ᅙᅳᅙ, ᖛᨓᖜ, ꖴᅩꖴ, ఠᨋఠ; // Naming your variables is serious business
|
|
-
-
fire2k


- Joined on 06-02-2010
- Posts 60
|
Zecc: fire2k:Ever heard of Node.js? Sure, your code needs a webserver in some form, but since you are running a DB-server anyway...
You don't need Node.js, a web server or a database server. All you need is a standalone JS implementation with a sqlite binding. Yes, technically SQLite is a database. Yes, there are also bindings to NoSQL and stuff. I doubt the original "haha, javascript is awful"-poster does consider these things to be real and probably meant to say "calls to a relational database" or something like that...
|
|
-
Page 1 of 1 (25 items)
|
|
|