|
Fehler posted:I actually had a good reason for this as well, as there was gonna be a final else that handled all lines after the third one. If you think that was a good reason to do this you need to quit programming forever!
|
# ? Mar 18, 2009 23:55 |
|
|
# ? Apr 19, 2024 04:33 |
|
Fehler posted:I actually had a good reason for this as well, as there was gonna be a final else that handled all lines after the third one. code:
|
# ? Mar 19, 2009 00:14 |
|
My task today at work is to get our software configured to send data to somebody else's SOAP service. I do this all the time, so it shouldn't be a big deal. This service is a bit different; it's expecting to receive a single argument to its function rather than a whole list of arguments like usual. This single argument is a huge XML document that just gets pasted into a node in the SOAP document. No, it's not a complex type. It means the WSDL file is almost useless now, defeating the purpose of SOAP. How did this happen??
|
# ? Mar 19, 2009 17:41 |
|
royallthefourth posted:How did this happen?? You've only ever used SOAP to communicate between services written using the same SOAP framework haven't you? SOAP and WSDL represent about 4 different protocols all disguised as the same standard.
|
# ? Mar 19, 2009 19:26 |
|
Ryouga Inverse posted:
code:
|
# ? Mar 19, 2009 19:32 |
|
Zombywuf posted:You've only ever used SOAP to communicate between services written using the same SOAP framework haven't you? I've communicated with lots of services, all written by people working at different companies. I've also written a couple services of my own, but never used a framework for it. I've seen poor design decisions with SOAP services before, but never seen an XML node represent another XML document. That's just ridiculous!
|
# ? Mar 19, 2009 19:45 |
|
duck monster posted:I think they are great, because it lets you have resources that really really should be singular , like data base connections, Janin posted:That code is C++, so "reference" is actually the insanely dangerous "any future code could change the variable used in this context to anything" kind, not Java/C#/Python copied pointers. Really, we need to write in dumb c++, just like there is a "simple english" wikipedia. heeen fucked around with this message at 19:57 on Mar 19, 2009 |
# ? Mar 19, 2009 19:55 |
|
Fehler posted:
eh. But your code is unclear: what if there IS only one line? Is that okay? It would seem to me that if I had to write special cases for lines 1 and 2, I should expect that the file will always have at least those two lines, and something else is an exceptional condition.
|
# ? Mar 19, 2009 20:02 |
|
heeen posted:Until you want to have a development database. Or until you want to have a second window. Or a second monitor. Actually, this is the second of two problems that singletons are specifically designed to solve. The first problem is the inherent "staticness" of a call to a global function; by using an instance method instead, you grant yourself the option of converting that to a virtual call without modifying any of the call sites. Obviously you could instead just modify the global function, but then you're stuck with an extra level of indirection; C++ would also allow you to turn the original function into a function-pointer variable of the same name, which is, er, not an appealing alternative. The second problem is that global data often doesn't stay global, in which case you'll eventually need an instance anyway. The important point here is that you're not supposed to repeatedly assume the globalness of a singleton; if every access to the singleton goes through the global accessor, you're completely sabotaging this advantage of the pattern. Instead, you should have only a few places in the code that read the global reference, and those places should pass around the reference to everything else that needs it. That way, you only need to modify those few places if the data ever becomes global.
|
# ? Mar 19, 2009 20:33 |
|
rjmccall posted:The important point here is that you're not supposed to repeatedly assume the globalness of a singleton; if every access to the singleton goes through the global accessor, you're completely sabotaging this advantage of the pattern. Instead, you should have only a few places in the code that read the global reference, and those places should pass around the reference to everything else that needs it. That way, you only need to modify those few places if the data ever becomes global. For instance, if designed correctly, declaring multiple "some_allocator" objects should work fine even though they may all use the same, shared, global pool underneath. Given its interface, which would include basic operations like allocating an deallocating blocks of memory, there should be no problem if at some point in time you decide to go back and change the type to use an individual pool per object. If you are using some static "get_instance" function to access your object instead of what I describe above, you can still use it appropriately as long as you only call "get_instance" in the same places you would logically grab a new instance of the type as though it were a factory. Once you obtain your object, pass it around like you would any other object (don't keep calling get_instance). The fact that only one instantiation actually exists should be an implementation detail. Using a monostate instead of an explicit global access point just makes proper usage more consistent with other types (and even more usable with generic code). In my opinion, what it all boils down to is that if your desired use of a singleton is based around the fact that you can provide global access to a single object, you're just making a pretty global, which is fine if that's what you want, but don't think you're making things any different by attaching a fancy name to it. All too often I see people say "man, I hate globals, I use singletons instead" and then proceed to use it as a global without giving it a second thought.
|
# ? Mar 19, 2009 21:29 |
|
That Turkey Story posted:In my opinion, what it all boils down to is that if your desired use of a singleton is based around the fact that you can provide global access to a single object, you're just making a pretty global, which is fine if that's what you want, but don't think you're making things any different by attaching a fancy name to it. All too often I see people say "man, I hate globals, I use singletons instead" and then proceed to use it as a global without giving it a second thought. Your post took a couple readings to hash out the actual meaning... and I've yet to see a pretty name for a singleton, just hugely long names with multiple colons. Interesting design perspective though, do you have any examples?
|
# ? Mar 19, 2009 23:17 |
|
I think this is what TTS is talking about :code:
|
# ? Mar 19, 2009 23:34 |
|
MarsMattel posted:I think this is what TTS is talking about : Now the cycle is complete.
|
# ? Mar 19, 2009 23:42 |
|
Kelson posted:Your post took a couple readings to hash out the actual meaning... and I've yet to see a pretty name for a singleton, just hugely long names with multiple colons. Interesting design perspective though, do you have any examples? I think he means 'singleton' is the pretty name. Because calling it a 'global' is the 'dirty' name, but when they use it just like a global that's all it is, just with a different name.
|
# ? Mar 19, 2009 23:54 |
|
Mustach posted:And now we flame each other over currying. Memoization is stupid! Why would I want evaluation to be LAZY when speed is a priority?
|
# ? Mar 20, 2009 00:34 |
|
That Turkey Story posted:Quoted for truth. I go so far as to say ditch the entire concept of direct global access completely and instead favor a monostate pattern with an interface and associated behavior that allows an internal implementation using either a shared global resource or an owned implementation, where the distinction is specifically designed to be an implementation detail. I.E. Consider a memory allocator that uses a shared memory pool for all allocations that you instantiate like any other type -- you just do some_allocator_type my_allocator. Instead of implementing your type as a singleton with a global access point simply because it uses an internal shared, global pool for all allocations, just implement it as any other type except that it internally has a shared state, given that the shared state can be viewed as an implementation detail by design. Wow, this has completely changed how I understand singletons (and given me actual respect for them). No one ever explained them as "like a factory, except it happens to return the same object every time," they were always taught to me as pretty globals.
|
# ? Mar 20, 2009 03:28 |
|
Kelson posted:Your post took a couple readings to hash out the actual meaning... and I've yet to see a pretty name for a singleton, just hugely long names with multiple colons. Interesting design perspective though, do you have any examples? I'm pretty sure I gave an example.
|
# ? Mar 20, 2009 16:27 |
|
That Turkey Story posted:I'm pretty sure I gave an example. Even TTS isn't willing to read his wall of text to answer that question definitely though.
|
# ? Mar 20, 2009 23:33 |
|
Here's a wall of text for you: Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer Ugg boots is a lovely programmer
|
# ? Mar 20, 2009 23:48 |
|
Continuing exploration has revealed that at least one programmer tried to use namespaces for organization, but "gave up because it was too much typing".code:
|
# ? Mar 21, 2009 05:11 |
|
This code was written by my boss:code:
Standish fucked around with this message at 10:15 on Mar 21, 2009 |
# ? Mar 21, 2009 10:13 |
|
Standish posted:This code was written by my boss:
|
# ? Mar 21, 2009 12:25 |
|
We have a self-serve advertising platform, and there are these navigation pieces at the top of the content with little titles under them. One of our past frontend guys decided this was a reasonable way to do it (the page id's, cat= values, curPage, and the pageTitles have been changed to hide who we are), because javascript is great for everything, right?code:
To make it even funnier, our VP of Technology found out and got a little angry, because we could've accomplished the same exact thing by adding a column to a db, and adding a few lines of ASPX to the frontend to automatically do this. This single piece created hours of work for anybody trying to create it. Oh yeah, this guy couldn't format JS properly to save his life, either.
|
# ? Mar 22, 2009 09:49 |
|
Here's a real gem from the codebase I'm working with right now. It's in the middle of a few hundred nearly uncommented message definitions.code:
|
# ? Mar 26, 2009 05:45 |
|
A lovely bit of code I had to write.code:
|
# ? Mar 26, 2009 16:29 |
|
Did I mention pyodbc yet? Because I'm pretty sure it's installed on the machine you're using, and works with mssql And there's an example somewhere in my old svn folder.
|
# ? Mar 26, 2009 18:49 |
|
Randel Candygram posted:Here's a real gem from the codebase I'm working with right now. It's in the middle of a few hundred nearly uncommented message definitions. I enjoy how the final comment is after the brace, almost as a "P.S.".
|
# ? Mar 26, 2009 21:01 |
|
code:
|
# ? Mar 26, 2009 22:29 |
|
Mick posted:
Clearly someone was getting paid per line.
|
# ? Mar 26, 2009 22:35 |
|
Mick posted:
|
# ? Mar 26, 2009 22:39 |
|
This was the best comment I ever read.code:
|
# ? Mar 27, 2009 12:57 |
|
Really small one but thought I'd share this, this snippet of Java is from a JUnit test suite:code:
|
# ? Mar 27, 2009 19:05 |
|
TSDK posted:Your avatar is perfect to go with that post. code:
|
# ? Mar 27, 2009 21:19 |
|
Must be an embedded whitespace script.
|
# ? Mar 27, 2009 21:23 |
|
Hmm I wonder why our test cases take so long to run...code:
|
# ? Mar 29, 2009 20:26 |
|
Mick posted:I think I like this one better. I promise this has been in (at least) the last two releases. This code.. is art.
|
# ? Mar 29, 2009 22:43 |
|
Strong Sauce posted:This code.. is art. No matter how many words you put inside the braces you must ask yourself: am I really doing anything?
|
# ? Mar 29, 2009 22:47 |
|
royallthefourth posted:No matter how many words you put inside the braces you must ask yourself: It's a pretty clever way to find out if the compiler accidentally generates new code for you.
|
# ? Mar 29, 2009 23:25 |
|
Can't actually post the code, but at work today I figured out that if you have the product I'm testing installed, anyone can create a webpage that can invoke any arbitrary dos command or change any setting in the registry with like three lines of setup.
|
# ? Mar 31, 2009 05:15 |
|
|
# ? Apr 19, 2024 04:33 |
|
I stumbled across this at work a while back. Somebody decided to be clever and make a data structure that could read any value from a bunch of different tables and queries. The setRow method is called on each row returned from a query. And they wonder why the appliction runs slowly.code:
|
# ? Mar 31, 2009 07:36 |