Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
POKEMAN SAM
Jul 8, 2004

Pardot posted:

But there is, and you know there is :colbert:

Hey some of us don't have your crazy GIGABYTE drives installed. I'm working on a machine with 4GB RAM and only 640MB disk drive. :awesome:

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

MrSaxamaphone posted:

Hope I get to do some of the WPF stuff we're looking at.

WPF is a coding horror.

POKEMAN SAM
Jul 8, 2004

Otto Skorzeny posted:

You sure about this? Last I heard C and C++ compilers were generally "loving terrible" at tco and trampolining

http://www.linux-kongress.org/2009/slides/compiler_survey_felix_von_leitner.pdf posted:

gcc has removed tail recursion for years. icc, suncc and msvc don’t.

POKEMAN SAM
Jul 8, 2004

clockwork automaton posted:

code:
string Counter::getStringOf(){
	if(total == 1){
		return ofToString(total) + " thing";
		
	}
	return ofToString(total) + " things";
	
} 

This one is my favorite, haha.

POKEMAN SAM
Jul 8, 2004

1337JiveTurkey posted:

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. :smuggo:

I always felt like such a retard for asking if I could do group projects by myself, but I sure as hell didn't want to explain, for example, in a Math class why I was writing a C# application to generate the linear equations for the linear programming problem. All of the other groups wrote out all of the combinations by hand (this was a scheduling problem.)

POKEMAN SAM
Jul 8, 2004

TagUrIt posted:

code:
double correctDegrees(double degrees) {
  while (degrees < 0) degrees += 360;
  while (degrees > 360) degrees -= 360;

  return toDegrees(toRadians(degrees));
}
:confused:

Wait wtf, after seeing the loops I missed the real horror of the return line...

POKEMAN SAM
Jul 8, 2004

Jonnty posted:

Is there any conceivable reason why you might think that was in any way sensible? Some standard return format or something?

When you find 2 lines with horrors in a 3 line function, and notice the third line is a return statement, you kinda just assume it might be horror-free.

POKEMAN SAM
Jul 8, 2004

ColdPie posted:

Excuse my stupid question, but is the horror just not using fmod? Not knowing about a poorly-named function doesn't seem like a horror to me, just a lack of familiarity with the standard library which ought to be corrected. I don't think I would blame someone for reimplementing atan2 either, given its name.

The while blah doesn't really bother me because it at least makes sense intuitively. This makes me cry though:

return toDegrees(toRadians(degrees));

Edit: I just realized that this code doesn't work like fmod. The range of the function is [0, 360] not [0, 360) :D

POKEMAN SAM
Jul 8, 2004

Avenging Dentist posted:

I would. The C standard library is really small. If you don't know C well enough to be able to use documentation when you want a really common function, you don't know it well enough to be getting paid to write code in it.

code:
float MathATan2f (float x, float y) {
    return atan2f(y, x);
}
lol

POKEMAN SAM
Jul 8, 2004

mr_jim posted:

Have we done names_with_underscores vs. namesWithCamelCase yet?

The horror that I see at work all the time is people calling ThisSortOfCasing "camel case with the first letter capitalized".

POKEMAN SAM
Jul 8, 2004
A solution to "database is locked":

code:
def executeRepeated(db, query):
	try:
		res = db.execute(query)
		return res
	except sqlite3.OperationalError:
		return executeRepeated(db, query)

POKEMAN SAM
Jul 8, 2004

Modern Pragmatist posted:

code:
if (1 != phase) {

Man I hate that backwards rear end poo poo.

POKEMAN SAM
Jul 8, 2004

Flobbster posted:

The only time I ever do something like this is when I'm in Java and I want to compare strings. Saying "foo".equals(str) instead of str.equals("foo") makes things a little more concise in the even that str could be null.

Yeah, in that case you're just avoiding the horror that is Java string comparison.

POKEMAN SAM
Jul 8, 2004

manero posted:

How long does this take to run?

I don't really understand that moon-language, but it doesn't sound that expensive (obviously it's a coding horror nonetheless) because it's only going to do IssueNumberSequence.create! 200,000 times (and I doubt it's expensive) and 20,000,000,000 comparisons for the find_by_number to work, assuming it's O(n). 20 billion isn't very many times for a computer to do something.

POKEMAN SAM
Jul 8, 2004

shrughes posted:

Did you just say lg? They never said "lg" when I was in school.

Kids these days!

Edit: Er, I mean, this is the real coding horror.

We always used lg(x) when it was base 2, log(x) for base 10, and obviously ln(x) for base e. Obviously it doesn't matter for asymptotic analysis like this, but yeah.

POKEMAN SAM
Jul 8, 2004

Hammerite posted:

code:
$reverse_string = implode("xxx", $reversed_array);
$reverse_string = str_replace("xxx", "", $reverse_string);
This bit in particular is a bit odd. Why not just use implode('', $reversed_array)?

Again, coding horrors thread. Logic need not apply.

POKEMAN SAM
Jul 8, 2004

Ryouga Inverse posted:

C# 3.5, so we can't have nice things like named and optional parameters.

That still doesn't excuse this:

code:
        public bool stuff(
            string command,
            string requestID,
            string couldBeAnObject,
            string request,
            string response,
            string ifThatThingWasAnObjectThisWouldntBeNecessary,
            params object[] additionalParams)
        {
            int responseCode = 202;
            string expectedRespCode = Success;
            string id = null;
            uint numberOfPendingResp = 0;
            int pendingRespInterval = 0;
            Header contentTypeHdr = ...;
            if (additionalParams != null && additionalParams.Length > 0)
            {
                int count = additionalParams.Length;
                if (count > 6)
                    count = 6;
                switch (count)
                {
                    case 6: contentTypeHdr = (Header)additionalParams[5]; goto case 5;
                    case 5: pendingRespInterval = (int)additionalParams[4]; goto case 4;
                    case 4: numberOfPendingResp = (uint)(int)additionalParams[3]; goto case 3;
                    case 3: id = (string)additionalParams[2]; goto case 2;
                    case 2: expectedRespCode = (string)additionalParams[1]; goto case 1;
                    case 1: responseCode = (int)additionalParams[0]; break;
                }
            }
:suicide:

edit: oh, and there are a ton of these.

I was going to say that switch statement looks like it belongs in a for loop, but holy poo poo I think that version may actually be worse.

POKEMAN SAM
Jul 8, 2004

Zhentar posted:

I've been starting to do some iPhone development for work. Today, I looked at the contents of a plist file for the first time. A snippet of it:

code:
<plist version="1.0">
<dict>
	<key>CFBundleDevelopmentRegion</key>
	<string>English</string>
	<key>CFBundleVersion</key>
	<string>1.0</string>
	<key>LSRequiresIPhoneOS</key>
	<true/>
</dict>
</plist>
:eng99:

WTF is the <true/> element for?

POKEMAN SAM
Jul 8, 2004

Plorkyeran posted:

Is the pattern <key>Key Name</key><datatype>Value</datatype> really that hard to figure out from that sample? It's an incredibly terrible design but it's not that confusing.

Oh, I didn't realize that the true went with the one above it. I had miscounted and assumed there were 3 pairs and then a stray true.

Yeah, with good whitespace it'd be easy to read/understand.

POKEMAN SAM
Jul 8, 2004

Mustach posted:

Hmm, there seems to be a case missing…

What case is missing? Obviously you can't sort with this, since it returns 0 or 1 instead of -1, 0, 1, but other than that what's wrong?

POKEMAN SAM
Jul 8, 2004

shrughes posted:

And MD5, or SHA-X, would be the wrong things to use.

Back when the stock PHPBB (I think) installations used MD5 with no salt or anything for hashing passwords/session cookies I was administrating an underground hacking forum, and one of our rival forums realized that they can impersonate our users by using the same MD5 hash of that user from their database on our forums and then they'd have access as that user.

What'd I do to fix this?

MD5(MD5($password))

:D


Also, I started keeping plaintext passwords in the database, too, so that when their members logged in to our forums we just had their password in plaintext, no middleman.

POKEMAN SAM
Jul 8, 2004

shrughes posted:

What? Where did they find the "MD5 of your password" field?

It was stored in your session cookie. Also this might've been IPB not PHPBB. The details are fuzzy.

POKEMAN SAM
Jul 8, 2004

Hibame posted:

When asked if they are going to fix it.
:btroll: "I don't know, it works for me."

Whenever we submit something that breaks on someone else's machine we always pull this out :D

POKEMAN SAM
Jul 8, 2004

Combat Pretzel posted:

I just wrote a short three number wide median algorithm using ?: notation. After I removed the helping parentheses, I got this construct out of it:

code:
m = y < z ? x < y ? y : x < z ? x : z : y < x ? y : x < z ? z : x;
Gotta hate certain C based syntax elements. :suicide:

this is awesome don't let anyone else tell you otherwise

POKEMAN SAM
Jul 8, 2004

Janin posted:

This isn't true at all, FYI -- good Haskell is roughly comparable to Ruby, better than Python, and much better than Perl.

Better than Python? Reading Python is just reading pseudocode that can be interpreted by a computer, too.

POKEMAN SAM
Jul 8, 2004

A very bad man posted:

Is that the same as being a programming nihilist?

I don't know if this has been posted yet, presenting the regex from hell
http://ex-parrot.com/~pdw/Mail-RFC822-Address.html

I think that gets posted every 16th page.

POKEMAN SAM
Jul 8, 2004

HFX posted:

This may be that Java accessors modifiers do not behave as they do in most languages. You should also consider Java's age, their resistance to breaking legacy code (and then doing it anyway), and JVM fault designs because of early versions.

Honestly, I'd rather have it the Java way instead of making things internal in C# just so that I can access a nested class's private field for special construction without exposing it to the entire namespace.

POKEMAN SAM
Jul 8, 2004

Zhentar posted:

Having to type an extra character to say what I mean is such a burden. Why can't the compiler just detect what I mean and ignore what I say?

What are you even talking about? I don't mean for the class's fields to be available throughout the namespace. Setting a field in a nested class as internal in C# isn't the same as setting it to private in Java...

POKEMAN SAM
Jul 8, 2004

king_kilr posted:

Pack it up, go home folks, this is the ultimate horror.

Yeah, seriously, camel-case functions? *shudder*

POKEMAN SAM
Jul 8, 2004

bobthecheese posted:

code:
<form name="GroupEditForm" action="<?=$currentscript?>" method="post" onsubmit="return checkGroupForm(this)">


This line itself is horror gold.

POKEMAN SAM
Jul 8, 2004

_aaron posted:

No god drat way.

This is awesome because it makes debugging so much easier. If you're in a debug build, have it print comments to the debug console so you know what's going on, in English!

POKEMAN SAM
Jul 8, 2004

Mustach posted:

What the gently caress kind of expensive are you talking about?

whoooooosh

POKEMAN SAM
Jul 8, 2004

npe posted:


It was every bit as wonderful as I expected it to be!

Holy poo poo good game you win.

POKEMAN SAM
Jul 8, 2004

npe posted:

:allears:

I love how one of them has data.Length < 7, and one has data.Length < 8. Obviously this is correct, but it means that there was a bit of attention paid to the functions...

POKEMAN SAM
Jul 8, 2004

Smugdog Millionaire posted:

Coding horror or no?

It might be be the best solution (better imo) but at least it does something you don't get from just writing the code out sequentially.


Why wouldn't you do this? (.NET 4.0) I don't know why you're using that Parallel ForEach poo poo.

code:
Task.Factory.StartNew(MyFunction1);
Task.Factory.StartNew(MyFunction2);
Task.Factory.StartNew(MyFunction3);
Task.Factory.StartNew(MyFunction4);

POKEMAN SAM
Jul 8, 2004

Smugdog Millionaire posted:

...

Here's an improved version of yours:
code:
WaitAndLogExceptions(
    () => {
        DoSomethingForOne();
        DoOtherThingForOne();
    },
    () => {
        DoSomethingForTwo();
        DoOtherThingForTwo();
    },
    () => {
        DoSomethingForThree();
        DoOtherThingForThree();
    },
    () => {
        DoSomethingForFour();
        DoOtherThingForFour();
    }
);


private static void WaitAndLogExceptions (params Action[] actions) {
    Task[] tasks = new Task[actions.Length];
    for (int i = 0; i < actions.Length; i++)
        tasks[i] = Task.Factory.StartNew(actions[i]);

    try {
        Task.WaitAll(tasks);
    }
    catch (AggregateException e) {
        foreach (var ex in e.InnerExceptions) {
            logger.LogException(ex);
        }
    }
}
I bet we can make it prettier, too.

POKEMAN SAM
Jul 8, 2004

Plorkyeran posted:

i.e. when it's not actually for-case?

It just happens to be a for loop creating the test data, and it just so happens to be a switch statement that does the validation, so yeah, it's not really for-case.

POKEMAN SAM
Jul 8, 2004

Munkeymon posted:

Naming your release after the last movie you saw isn't totally unreasonable. I could see it giving a movie buff some context to help pull up associated memories.

I really hope you're joking/trolling here.

POKEMAN SAM
Jul 8, 2004

Otto Skorzeny posted:

Cut some slack Sam, off-by-one errors are one of the two really hard problems in computer science (the other two, of course, being cache invalidation and naming things).

As we say where I work: off by one errors really suck when you're working with booleans.

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

Kamikaze! posted:

I like this one in Python:
code:
>>> def a(b,c={}):
...     c[b]=True
...     print c
...
>>> a(1)
{1: True}
>>> a(2)
{1: True, 2: True}
>>>

I don't really have a problem with that because I understand it and it isn't something you're likely to do accidentally all the time. It's just a parameter with a default value that happens to be something that you'd store a reference to, so the next time you execute a(something) c is going to be pointing to the same object because it's only instantiated once.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply