|
dwazegek posted:One of my gripes with it is the "retVal" variable (it always seems to be named that way), in the vast majority of the cases, the first "real" value that is assigned to it, is the value that it's going to have at the end of the method. So why not return the value immediately? RetVal is useful if you're caching outputs somehow like in a map. Since many cache implementations can asynchronously dump some data between testing for its presence and actually getting the data itself, a common idiom is to get the item in question and then test for nullity. If it's there, we got a value. If it's not, we got null and need to switch to Plan B.
|
# ¿ Mar 22, 2008 06:32 |
|
|
# ¿ Apr 28, 2024 22:31 |
|
rotor posted:jesus christ what the hell Considering that it's a 128 bit number, I'm guessing he tried obfuscating things by just going through and doing a find-replace with the MD5 of all of the variable names, possibly flipping the occasional bit to make everything a valid identifier.
|
# ¿ Apr 2, 2008 20:52 |
|
This'll probably horrify some posters, but I like:code:
|
# ¿ May 10, 2008 03:48 |
|
Jeffrey posted:I like this, except maybe I'd line up the question marks and possibly the colons, especially if there were more cases. Extra formatting can make it more of a pain to change things later although the question mark would make a decent column delimiter. theg sprank posted:Were you at any point in your life a LISPer? To be quite honest, I could never figure out what's proper indentation in Lisp for the life of me even if the other stuff makes sense.
|
# ¿ May 13, 2008 02:54 |
|
MORE CURLY FRIES posted:Sorry if I'm being a bit groggy here, but what's wrong with a switch in a for statement? Just write them sequentially instead since all that code does is call case 0 and then case 1, but in an obfuscated manner.
|
# ¿ May 26, 2008 03:37 |
|
shopvac4christ posted:You know, it's so difficult to use an integer as an index on an array, we should just throw an eval around it instead. If that wasn't autogenerated, there is no God.
|
# ¿ Jul 1, 2008 21:36 |
|
Ryouga Inverse posted:the real wtf is that it actually saves to the file (without asking) and then asks if you want to save the file, but really it's asking "do you not want to delete the file?" I do something similar when I'm supposed to write out an error log with an execution trace only if some error occurs. At the end, if it succeeded with no errors, I delete it. It's perfect because if it fails to delete for some reason or another, then I needed the log file because that's an error.
|
# ¿ Jan 28, 2009 15:59 |
|
A copy of that regex takes about 2MB of RAM and 2 ms to compile into an internal FSM representation on my computer.
|
# ¿ Feb 12, 2009 06:53 |
|
Dijkstracula posted:I admit I can't even imagine why an implementation of TSP (or, even any of its variants - bitonic TSP, euclidean TSP, etc) would take anywhere near 3000 lines ADD CURRENTEDGEWEIGHT TO TOTALEDGEWEIGHT GIVING TOTALEDGEWEIGHT,
|
# ¿ Jul 30, 2009 18:31 |
|
http://java.sun.com/javase/6/docs/api/javax/xml/transform/TransformerFactory.html Apparently just having an XSLT transformer isn't enough. It needs to be instantiated using a factory for extra flexibility. At first I thought it was for the ability to read input and write output as streams, SAX events, STAX events, and DOM trees with the same API. Now I've learned that it's also great for use cases such as the developer having one XSLT implementation which accepts blank namespaces and the server having another XSLT implementation which suffers a fatal error whenever it encounters a blank namespace.
|
# ¿ Jul 31, 2009 22:16 |
|
Zombywuf posted:Seriously? That's an Eclipse quirk. IntelliJ is perfectly happy to list the class structure in the sidebar in alphabetical order while leaving the code well enough alone. In any case if it's impossible to find anything in a class without putting every member in alphabetical order, the class is probably too drat big to begin with.
|
# ¿ Aug 7, 2009 19:35 |
|
Otto Skorzeny posted:By the way, does Java make any guarantees as to the layout of the class based on the order of declaration of members? There's no guarantees or need to do so. The class file format begins with some identifiers and then a constants pool. Everything else within the file refers to the constants pool including the class name itself. When the class is loaded the constants pool is interned, creating exactly one canonical copy of each constant in the permgen space which everything refers to. Since method, class and field references are also in the constants pool, interning dynamically links the program.
|
# ¿ Aug 8, 2009 04:15 |
|
I learned an interesting/disturbing use for XSLT when I needed to add some unit tests to some XML data exporter recently. It turns out the exporter doesn't have unit tests in the traditional sense but instead has one unit test. This test is naturally thousands of lines long and spread over several files and includes a set of unit tests for testing itself. This is only prudent for a multithreaded framework which appears* to run different programmatically constructed exports selected using cost/export time based heuristics. These exports are then tested using a combination of XSLT stylesheets which use patterns that cause the transformation to fail when their associated XPath expression matches. Now all I have to do is figure out how those stylesheets get associated with the proper permutations of options and then add my own somewhere in there. *I'd be more sure if there was a single drat useful comment in the whole thing.
|
# ¿ Aug 29, 2009 03:51 |
|
mr_jim posted:Time works the same way. So my stack is actually a cube?
|
# ¿ Sep 5, 2009 20:40 |
|
yaoi prophet posted:What exactly does '3rd-level damage' mean? Sounds to me like it had effects which showed up several modules away from the original cause of the problem. Like a classpath error in one module being traced back to a Kodo error which was caused by yet another module failing to deploy because of what ultimately amounts to the clustering configuration referring to a host that doesn't resolve.
|
# ¿ Oct 4, 2009 23:13 |
|
I'm stuck at work diagnosing some build error that only happens on my system in a perl script somewhere under seven layers of antcall with some gratuitous javascript tossed in the middle. edit: I forgot about the little bit which runs some taglet parser over an autogenerated buildfile. 1337JiveTurkey fucked around with this message at 03:44 on Dec 10, 2009 |
# ¿ Dec 10, 2009 03:12 |
|
Zombywuf posted:Dunno, what if you want to implement a sort command? If you want a CLI command then use the -client rather than -server command line option and complaining that the runtime environment uses more RAM and takes longer to start. If you want a language that lets you write fast code while making gratuitous system calls, it's down aisle 7 between the pixie dust and unicorn farts and beneath the functional compilers that actually generate parallel code.
|
# ¿ Feb 1, 2010 07:26 |
|
I was teaching some middle schoolers how to use Game Maker's visual programming interface and it turns out that a comment block immediately after an if or an else statement acts in exactly the manner that ColdPie's describing. It sucks when something like that comes up during a live demonstration of how and why you should always comment your code.
|
# ¿ Mar 27, 2010 01:44 |
|
Toady posted:On a somewhat related note, why are many new coders full of distrust and want to roll things on their own? No matter how much you tell them it's a bad idea, they will not listen to you. They'll even be polite about it, but you'll never convince them otherwise. We teach new coders how to write programs that open a file, read a character stream from them, parse it and then write it to another file. We don't teach them how to do the same task with an ESB and data binding API. When I graduated from college, I didn't really trust the libraries and frameworks I now consider indispensable because I didn't understand them but I did understand the Unix model and I did understand how to parse character streams. It took experience before I could really appreciate the level of abstraction that they operated at, and I gained some of that experience by reinventing the wheel on occasion.
|
# ¿ Apr 15, 2010 00:09 |
|
Sprawl posted:Both of those ways are dumb because then you have to change too much should you need to make a change. You should just make an custom generic and be passing that. That sort of ties into the whole thing about beginning programmers and tools in that it's debating the architecture of an essentially solved problem. Just use an ESB and a data binding API, create a Reservation class and get down to the important parts.
|
# ¿ Apr 16, 2010 16:08 |
|
Broken Knees Club posted:Is MUMPS an elaborate practical joke? Most modern dynamically typed scripting languages share the use of an associative array as their primary/only data structure. In that sense, the language is somewhat ahead of the curve and it got there because medical records keeping really needs that sort of functionality. People come down with new problems that require new types of tests and treatments. The relational model doesn't fit very well to it, whereas associative arrays are just what the doctor ordered. Everything somehow being a row in a database is another way of describing single level storage, which is quite popular outside of OS derivatives of CP/M and UNIX. In Multics, the primary method for accessing files was effectively mmap and there wasn't a need for some dedicated API for writing to disks since a file was just another segment in your process memory space. The UNIX model of files being streams of bytes took off due to the lack of hardware support for that in minicomputers, microcomputers and personal computers. These days everything has virtual memory support, though and the only excuse for multi level storage is that it's what everyone's used to.
|
# ¿ Apr 25, 2010 23:09 |
|
Shumagorath posted:I'm not sure what virtual memory has to do with that, but hasn't Microsoft been trying to bring this back for WinFS for a decade now and they just keep getting held up? WinFS is more than just single level storage in that it's got searching plus pretty much a full OO database with sharing and permissions and every bell and whistle that could possibly exist. SLS on its own simply treats disk storage as plain old memory and RAM as cache. Multics used both segmented and paged memory, and treated every file as a segment that could be mapped into a process space. File reading and writing was performed simply by reading and writing into that segment and the OS would handle it by mapping the pages to memory for reading and writing dirty pages to disk. Since modern operating systems already do have mechanisms like mmap, I guess that you could say that we do have SLS of a sort as an option although the flat memory space makes it difficult to map the whole file.
|
# ¿ Apr 26, 2010 07:49 |
|
Amusing anecdotes about systems programming on the VAX 11/780 are truly the fons et origo of all best programming practices.
|
# ¿ Apr 27, 2010 23:53 |
|
BattleMaster posted:The only good partner in university is no one at all. I once had a professor who told me that I had to do one project individually since group projects amounted to having three people watch me do all the work.
|
# ¿ Apr 28, 2010 06:32 |
|
Somewhat more questionable is that Excel rounds up, VBA for Excel rounds to even and some contractors we hired didn't quite get that distinction.
|
# ¿ Jun 12, 2010 21:08 |
|
Section 1.4.4.6: Wherein we learn why referential integrity is actually badquote:There are so many problems with foreign key constraints that we don't know where to start:
|
# ¿ Jul 1, 2010 03:31 |
|
dark_panda posted:Definitely a joke. The entire blog is hilariously bad so yeah, definitely a joke. I just wish there were more comments in the comments sections from people taking the bait. The one thing that makes me think it's real is that "Reinvent the Wheel with Ground-up Teleporters" is practically a design pattern.
|
# ¿ Jul 7, 2010 00:30 |
|
dark_panda posted:Nah, it's just too good to be real. I mean, it hits all the right notes so well: I'm sort of used to seeing Verner cyphers using a plain old PRNG, home-cooked reference counting in Java to 'help' the GC, code generation driven by a >300kB .xsl file and a CVS repository with nightly branches and tags for major code branches. There is literally no code so utterly perverse in its design or implementation that I couldn't believe it's real but you're right that the density of the idiocy pretty much had to be by design. At least I hope so, since I'd hate to think that there's production code out there written by someone who thinks that using 20 MB to store an interned string is a great way to save memory.
|
# ¿ Jul 7, 2010 03:58 |
|
Plorkyeran posted:Does that make PHP Stalin? No, .NET is Stalin and Mono is the People's Republic of Tannu Tuva. PHP is probably Imperial Japan or something.
|
# ¿ Sep 30, 2010 23:19 |
|
Sewer Adventure posted:Yeah but still they should ditch the decimal point and treat the numbers as cents It still isn't going to work if you do anything which involves multiplying by non-integral numbers such as interest rates. Even then the interest rates still won't work unless you can express them as the sum of several powers of two. The least that can be said is that they're not something like GTINs. Handling those unambiguously when reading in an Excel file is not fun.
|
# ¿ Feb 17, 2011 06:36 |
|
Hammerite posted:"Content-oriented"? I've not heard that before. What's an example of something that isn't content-oriented? Any site where viewing content created by the site owner or someone else is a means to an end rather than an end in and of itself. You can go to Amazon just to read reviews and look at book covers, but most people go there to buy stuff.
|
# ¿ Mar 4, 2011 02:58 |
|
It's more of an irk than anything else, but the Scala compiler treats all tabs as eight spaces and I've got IDEA set up with 4 space tabs so all of the error messages end up pointing to the wrong spot on the line.
|
# ¿ Mar 11, 2011 02:39 |
|
pokeyman posted:Dot is "any one character", star is "zero or more times". So the empty string is indeed matched by .*. Beyond that any string is matched by .* because it eagerly evaluates. Even if you took out the ^ in the middle, ^(.*)(ox)$ can never match anything.
|
# ¿ Apr 13, 2011 03:23 |
|
You have to explicitly tell the standard Java regex to backtrack with (.*?) because it can significantly affect performance.
|
# ¿ Apr 13, 2011 03:48 |
|
Hammerite posted:http://stackoverflow.com/questions/6163683/cycles-in-family-tree-software The problem is really just a data error and can easily be solved by simply killing everyone involved and removing their memories from the annals of history.
|
# ¿ May 29, 2011 04:09 |
|
Doc Hawkins posted:We can learn from their optimism.
|
# ¿ May 30, 2011 04:13 |
|
pokeyman posted:1. It's ugly. quote:2. That's the whole job of a bloody search engine!
|
# ¿ Jun 4, 2011 09:19 |
|
Aleksei Vasiliev posted:writing code without looking at it is some seriously zen poo poo This is generated HTML 99 times out of 100 so apart from reviewing developed code for correctness people won't be looking at it anyhow.
|
# ¿ Jun 4, 2011 16:48 |
|
pokeyman posted:This admirable goal has nothing to do with the posted example, which in fact adds one div and one span that were not present in the original. code:
quote:We're talking about a new specification that adds data. As of a month ago, precisely zero websites were using it. What data is being taken away here?
|
# ¿ Jun 4, 2011 17:38 |
|
|
# ¿ Apr 28, 2024 22:31 |
|
pokeyman posted:HTML does documents very well, and I'm not sure it was ever seriously offered as a language to describe structured data, so why should it do that very well? As you point out, there are better tools for that job. Yet another attempt to bolt some attributes on to HTML and call it a data description language seems wrongheaded. And ugly. Really in that respect I couldn't agree with you more. HTML really does suck at structuring data in any meaningful manner. If there's any reason people use HTML with microformats at all, it's institutional inertia. My issue is that the second half of <structured data store> + <store to html transformation> should be pushed back as far as possible and the structured data should be available as long as possible. Microformats at least keep some structured data available longer and therefore more useful to tools other than plain old web browsers.
|
# ¿ Jun 5, 2011 08:41 |