|
Today I'm writing a WCF web service to wrap an excel spreadsheet so that the team responsible for the sheet can update the calculations done on the production server without going through the dev team or any sort of change control.
|
# ? Aug 18, 2011 16:05 |
|
|
# ? Apr 28, 2024 19:34 |
|
Ensign Expendable posted:I saw this in production code before. Sadly, I fixed it and I can't be bothered to dig through subversion, but it was very similar. A dozen or so constructs, with hardcoded (identical) UI elements for each, a few boolean flags, three ArrayLists, some Strings. And lots and lots of if statements. When I rewrote the class to use a HashMap and proper OOP, I think it ended up being about a tenth of its original size. I had to do something similar as well; it was because the guy who created the original table denormalized it into setting / value pairs. The table looked like this: code:
|
# ? Aug 18, 2011 18:20 |
|
Scaramouche posted:I had to do something similar as well; it was because the guy who created the original table denormalized it into setting / value pairs. The table looked like this: wait, how did this even work?? Surely to get the value of a setting it was just doing: code:
|
# ? Aug 18, 2011 19:29 |
|
Profane Obituary! posted:wait, how did this even work?? Surely to get the value of a setting it was just doing: I bet it goes like this: code:
|
# ? Aug 18, 2011 19:42 |
|
^^^ Exactly. It was an enormous pain in the rear end, especially because in that year before we fixed it they'd be adding totally new 'Setting's, and I'd have to renumber the goddamn interface/update method. There's 38 settings now. The real sad thing I guess, is that when I did my half all I did was make a central array of settings, and then create controls/write updates based on going For...Next through that array. So I'd have say 30 lines on instantiation, but only 3 lines per operation (For, <something>, Next). I showed it to the first guy who had hundreds of hardcoded statements (e.g. the Dims, the assignments, etc.) and he just said 'oh' and looked kind of sad.
|
# ? Aug 18, 2011 20:46 |
|
baquerd posted:I bet it goes like this: Oh Jesus, you're probably right.
|
# ? Aug 18, 2011 20:47 |
|
I wish I had a dollar for every time I've had to explain to a senior developer that the order of a result set is undefined unless the query has an ORDER BY clause
|
# ? Aug 19, 2011 07:25 |
|
But they go into the table in a certain order!
|
# ? Aug 19, 2011 07:43 |
|
here's a cool thing, it's the run loop for erlang https://github.com/erlang/otp/blob/dev/erts/emulator/beam/beam_emu.c im not going to quote it because it's 6500 lines and i don't feel like i could do it justice, but just click and have a look
|
# ? Aug 19, 2011 08:04 |
|
it has a bunch of op codes and a dispatch mechanism vm code is never going to win beauty contests
|
# ? Aug 19, 2011 08:08 |
|
NotShadowStar posted:But they go into the table in a certain order! But tables have primary keys! Surely THAT'S the default order! Goat Bastard fucked around with this message at 08:20 on Aug 19, 2011 |
# ? Aug 19, 2011 08:15 |
|
tef posted:it has a bunch of op codes and a dispatch mechanism fair enough, you're right. it's not a horror, but i don't envy the people who have to maintain it
|
# ? Aug 19, 2011 08:33 |
|
Boss (on Tuesday): This [silly quiz program] needs to have these features by next Tuesday, do you think you can do it? And don't worry about it, if it's not done, we'll just use pen and paper for the quiz. Me: I haven't really coded that much (or at all, really) with C#, but yeah, probably. By Friday around noonish, the program has pretty much all the features requested (but is in need of some testing). And it has some silly animations, like the currently active contestants names flocking around a "black hole" on the right side of the screen. Boss, Friday, 2 pm: Oh, can you make the screen bigger, currently only the top 17 contestants on the ranking list fit on the screen. Me: Well, sure ( I guess I'll change some of those text positions to be relative to the screen-size like I originally planned ) Boss, Friday, 4 pm: Now can you make the font for the contestants bigger. Also, could you make the font scale with the number of contestants or the list scroll or make the ranking list two columns so that all ~30 contestants can fit on screen. Oh, and if a client drops or cancels, their name is left on screen flocking. And could you make the server save its state in case it crashes or needs a restart. Me: Okay yes, I can change the font, but not very often. I've used hardcoded offsets so that the text doesn't overlap, because this was supposed to be a silly toy program, so changing the font requires me to change the value of a bunch of constants. That other stuff can be done, but gently caress, I could have used these requirements like 3 days ago, not at 4 pm on Friday I guess this overlaps with the poo poo that pisses me off thread.
|
# ? Aug 19, 2011 16:07 |
|
Goat Bastard posted:I wish I had a dollar for every time I've had to explain to a senior developer that the order of a result set is undefined unless the query has an ORDER BY clause Varrays and pipelined functions called through the table operator without any subsequent joins in Oracle should be in order. At least I hope they are since I just ended up writing a query which relies on that to avoid generating a crapload of extra data just so I could sort it.
|
# ? Aug 19, 2011 17:01 |
|
1337JiveTurkey posted:Varrays and pipelined functions called through the table operator without any subsequent joins in Oracle should be in order. At least I hope they are since I just ended up writing a query which relies on that to avoid generating a crapload of extra data just so I could sort it. Sure, as long as you ordered the rows inside the function. That's sort of a special case though.
|
# ? Aug 19, 2011 21:44 |
|
Goat Bastard posted:I wish I had a dollar for every time I've had to explain to a senior developer that the order of a result set is undefined unless the query has an ORDER BY clause My organization is currently switching over from the Paradox database to Oracle, which means that there are thousands of SQL queries throughout our massive legacy program that need to have columns and tables renamed/escaped (different reserved words) and order by clauses added (Paradox orders the data in tables by primary key(s), and queries and cursors always return data ordered by the primary keys). We had some terrible developers in the past who were really lazy, and Paradox encouraged some bad habits. I managed to put a huge band-aid over the problem by writing a SQL parser to auto-correct/escape the column names in queries (a little difficult since I had to actually parse the query to avoid escaping legitimate uses of reserved words). I also wrote a function to query the Oracle database for its primary keys and cache them, then append them to queries against single tables that don't have an order by (as determined by the parser).
|
# ? Aug 20, 2011 01:10 |
|
Found another Dive into Python horror: in its example of file IO, it uses magic numbers instead of telling you 'hey the os module has some relevant constants you should use':quote:The seek method of a file object moves to another position in the open file. The second parameter specifies what the first one means; 0 means move to an absolute position (counting from the start of the file), 1 means move to a relative position (counting from the current position), and 2 means move to a position relative to the end of the file. Since the MP3 tags you're looking for are stored at the end of the file, you use 2 and tell the file object to move to a position 128 bytes from the end of the file.
|
# ? Aug 22, 2011 07:09 |
|
See this is why typed enumerations are a good thing.
|
# ? Aug 22, 2011 08:02 |
|
yaoi prophet posted:Found another Dive into Python horror: in its example of file IO, it uses magic numbers instead of telling you 'hey the os module has some relevant constants you should use': The official library reference suggests the use of constants or magic numbers is correct, so I guess Mark just wanted to save bandwidth. xf86enodev fucked around with this message at 08:39 on Aug 22, 2011 |
# ? Aug 22, 2011 08:29 |
|
The Unix lseek() function originally didn't have the SEEK_SET/SEEK_CUR/SEEK_END macros for the whence parameter and you were expected to pass 0/1/2 directly. There is no excuse for that stupidity to be propagated to Python, though.
|
# ? Aug 22, 2011 08:49 |
|
xf86enodev posted:The official library reference suggests the use of constants or magic numbers is correct, so I guess Mark just wanted to save bandwidth. He was probably referring to the use of 2 instead of os.SEEK_END. The python.org example only uses a magic number for the number of bytes to read, not for the seek mode. The number 128 in the Dive Into Python example is also something that could be put in a constant like MP3_TAG_SIZE or whatever, but that isn't a constant you can expect Python itself to know about.
|
# ? Aug 22, 2011 08:54 |
|
code:
|
# ? Aug 22, 2011 14:11 |
|
php -r 'var_dump("\n\n0099999999999999991111111111111111" == " 99999999999999990000000000000000");' recall when strings are treated like numbers, any leading whitespace or 0 is truncated
|
# ? Aug 22, 2011 14:15 |
|
https://bugs.php.net/bug.php?id=55439quote:Bug #55439 crypt() returns only the salt for MD5 quote:[2011-08-19 22:19 UTC] stas@php.net
|
# ? Aug 22, 2011 18:29 |
|
I'd call that a feature. Leave it in to get people to stop using MD5.
|
# ? Aug 22, 2011 19:42 |
|
code:
|
# ? Aug 22, 2011 19:49 |
|
I write code like that all the time. It owns.
|
# ? Aug 22, 2011 20:23 |
|
meinstein posted:
As someone who just read the Law of Demeter paper this weekend, I think to myself, "Ohhh this is the poo poo they're talking about."
|
# ? Aug 22, 2011 23:43 |
|
It's not really that much of a horror. Needs a comment describing what it does / the expected format of the Word document, and probably some better error handling / checking for nulls, but that looks like fairly standard Linq to XML. The Open XML SDK was always a bit horrible. It's enough to make you miss PIAs sometimes.
|
# ? Aug 22, 2011 23:50 |
|
meinstein posted:
Couldn't you use an xpath? code:
|
# ? Aug 22, 2011 23:54 |
|
It's doesn't look so bad if you add some whitespacecode:
code:
|
# ? Aug 23, 2011 00:21 |
|
BonzoESC posted:Couldn't you use an xpath? In my opinion, XPath/pre-Linq-to-Xml processing isn't great in .NET. It's painful having to mess around with Xml namespaces and the libraries and concepts aren't very intuitive. Additionally, the Office Open XML format is quite verbose and complex and does some surprising things that can make XPath a bad choice. The documents are composed of several zipped folders, Xml files and binary resources. Case in point, Excel supports drag-and-filling of a formula into adjacent cells, with relative cells changing as the columns and rows change. However in the Xml, the adjacent cells are stored with a reference the formula in the master cell, with interpolation of the actual formula being done at runtime. I had to parse the bloody things once, that sure was fun! So yeah, Linq to Xml coupled with the OpenXML SDK is actually the sanest solution here, apart from possibly using the PIAs if performance isn't a problem and you don't mind all the 'joys' that come from running Word in headless mode.
|
# ? Aug 23, 2011 00:39 |
|
tef posted:it has a bunch of op codes and a dispatch mechanism Yeah, but they're pretending to write a compiler. If they wanted to do that they should have done so. As it stands, that is horrific code.
|
# ? Aug 23, 2011 15:00 |
|
Just came across this gem while looking for stuff onlinecode:
|
# ? Aug 25, 2011 10:30 |
|
I couldn't figure out how to make this code unmanageably nested, but that's not going to keep me from using that rightward sloping style that I'm so fond of.
|
# ? Aug 25, 2011 19:37 |
|
Classicist posted:I couldn't figure out how to make this code unmanageably nested, but that's not going to keep me from using that rightward sloping style that I'm so fond of. but he starts indenting things that don't even need to be indented, what in the gently caress is going on!
|
# ? Aug 25, 2011 20:07 |
|
Sweeper posted:but he starts indenting things that don't even need to be indented, what in the gently caress is going on! Copy/paste that auto-indents further and then isn't corrected at a guess.
|
# ? Aug 25, 2011 20:09 |
|
Was feeling nostalgic for the late nineties and decided to look up the clusterfuck that was Hotline (basically Mac BBS software) back in the day. Most of it is management fuckups (terrible oversight) and hinks being horrible at dealing with people, but this stood out:quote:36. According to Mr. Spearritt, on two occasions (one in late 1996 or early 1997 and the other in August 1997) he requested Mr. Hinkley to backup all source code on Redrock's A2BNT1 UAM server. This occurred after Mr. Hinkley was unable to make a change to SPFS because he was unable to locate all the source code. In his witness statement dated 16 July 2000 (Exhibit H 16) Mr. Spearritt said: I know Subversion & git etc are all newer than this, but CVS was hardly unknown at the time. Uploading a compressed archive of the source tree each month...
|
# ? Aug 25, 2011 22:35 |
|
Carthag posted:Was feeling nostalgic for the late nineties and decided to look up the clusterfuck that was Hotline (basically Mac BBS software) back in the day. Most of it is management fuckups (terrible oversight) and hinks being horrible at dealing with people, but this stood out: We can just put "CVS " as the response to that.
|
# ? Aug 26, 2011 00:17 |
|
|
# ? Apr 28, 2024 19:34 |
|
Sinestro posted:We can just put "CVS " as the response to that. I got this: rsync over ssh to rsync raw CVS repos, because Oh yeah, in the year of our lord 200X. Luckily it wasnt my team but the team sitting next to us interfacing with an outsourcer. We used the CVS protocol to update CVS repos (My team updated to svn after I left)
|
# ? Aug 26, 2011 01:11 |