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
Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Don't you have some sort of standards wherever you work in which one of you (I'm assuming him, since I hate his style) is blatantly breaking a rule?

Adbot
ADBOT LOVES YOU

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

king_kilr posted:

If you think that's a coding horror, your codebase is probably ok. I can think of a totally valid reason for that. The Color class isn't under your control and features general color management things, for your app you want to have a consistant UI, and you're starting with their definitions of what constitutes DARK GREEN, but that might be changed in the future.
..and if that changes in the future, so does COLOR_DARK_GREEN. What?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
One thing I can think of there is that the SelectionChanged event, if subscribed to, could throw an exception. Even so, I wouldn't be any means call this a 'horror' of coding, just not good practice.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Daald posted:

code:
            int wastedSpace;
            int result;

            if (Int32.TryParse(input, out wastedSpace))
            {
                result = Int32.Parse(input);
            }
I want you to try to parse this integer.

"Okay. I've got it! I've successfully parsed the integer, and the value is--"

NO! WAIT! You said you were able to parse the integer?

"Yes..."

Alright, I want you to parse the same integer again, and let me know what you get.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

oneinchhard posted:

code:

public class SomeClass
{
    public string SomeString1 { get; set; }
    ...
}

...elsewhere in the code:

string someVar = someClassInstance.SomeString1.ToString();

:negative:

This type of poo poo is all over this project that was handed off to me to optimize. Also:

code:

StringBuilder sb = new StringBuilder();
sb.Append("SELECT field");
sb.Append("FROM table");
sb.Append("WHERE field = ");
sb.Append(someVal.ToString());

string sql = sb.ToString();

...there are probably 100 DAL methods that have this crap in there.

:smith:

Going to school to be a nurse. 15 years of this loving poo poo...
Why are either of these 'horrors?'

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Hah, I wasn't even thinking of SQL injection; I was more focused on the unnecessary use of StringBuilder for that particular set of strings.

But for the first one, oneinchhard, yes, I understand why it's wrong. I just don't think it's a 'horror.' In fact, it's completely harmless and could easily have been introduced through a quick refactoring.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
At least you don't have to look at at that abomination combined with some anime quote every time you post.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Lysandus posted:

This might not be a horror for some of you but gently caress.

code:
if( bananas )
     grabBanana();
God drat I don't care if it's one line. Put some {} on that poo poo.
This is a preference and probably the furthest thing from a horror I can think of. Follow your team's guidelines when it comes to this one.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
The code following an if statement should never be more than one line regardless, so it's a non-issue.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Yeah, uh, I was joking by the way.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
It's possible that someone just started creating a class that implements some interface (error / notify) but forgot to finish it, and hopefully forgot to even hook it up to anything. Not really that unusual or horrible.

Orzo fucked around with this message at 23:26 on Nov 22, 2010

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Oh. That is horrible then.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

ColdPie posted:

Hahahahahahahahahahahaha
Missing why this is funny except for a childish jab at IE, isn't IE9 supposed to be wicked fast, like way faster than Chrome/Firefox/Safari?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Janin posted:

Interestingly, it might in reality be even slower; IE was caught cheating on Sunspider, by special-casing a few particular functions. Inserting things like "if (false) {}" into the code, or changing the order of variable assignment, can cause it to revert to previous (slow) performance.
I'm not an IE apologist by any means, but this issue is not as simple as 'they were caught cheating' and it's irresponsible to state that as if it were true.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Vanadium posted:

So it is dead-code analysis that gets broken by dead code?
You make it sound like writing something to eliminate 'dead code' is trivial. It isn't. You have to be extremely careful when writing an optimization like that since it's so dramatic (removing entire blocks of code). Who knows what the internal implementation is? All we know is that adding some things makes it not work anymore, and even if they look like completely trivial additions, it's entirely plausible that the algorithm pessimistically gives up (as it should) rather than making the statement that Microsoft is cheating (poorly) on one of many, many browser tests.

Or maybe you were just making a humorous statement that wasn't meant to be taken seriously, either way I'm just trying to point out how absurd the argument against Microsoft here is.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Has somebody written some test benchmarks (not just altering the Sunspider one) to see exactly what the optimizer can and can't do?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Maybe it used to be something else and the parenthesis were left in.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

dwazegek posted:

Constructor arguments are for scrubs:

code:
public static string Argument1Init { get; set;}
public static int Argument2Init { get; set;}

private string _argument1;
private int _argument2;

public SomeClass()
{
  _argument1 = Argument1Init;
  _argument2 = Argument2Init;
}
(names are changed)
oh my god, this is horrible

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

shrughes posted:

You're trolling, right? Or maybe you're just stupid.
Are you serious here or are you just really out of touch with reality

Orzo fucked around with this message at 23:08 on Mar 7, 2011

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Lysidas posted:

This is a good point, but if you're learning introductory programming it isn't really worth it.
The problem with this example though is that the thing they teach you (single exit) is more complicated than the default, which is to just return wherever you want in a method. So not only are they teaching you something incorrect, they're making your life harder.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

A A 2 3 5 8 K posted:

I had to show a professor once how to use a debugger. This was in the lab for a more coding- than theory-centered course. He was learning C++ along with the rest of the class, he was just a week or so ahead in the book.
You can be competent in many, many areas in computer science without ever touching C++ or a modern debugger. I don't think you could say the same about memory addresses, but I could be wrong.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Beef posted:

It's a teaching horror to just start with "Well ignore all this, but start your programs with 'public static void string args.'
Why? If you really don't know anything about programming, there are certain things you need to understand before method signatures, access modifiers, and argument lists. Have you ever tried to teach any programming to a complete newbie? The entrypoint signature can be overwhelming. Even many introductory books say 'we'll come back to this later, but for now you always need to have this block of code for your program to run.'

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
reminds me of that old 'object calisthenics' thing

http://binstock.blogspot.com/2008/04/perfecting-oos-small-classes-and-short.html

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
what are the comments like, is anyone a member?

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

TasteMyHouse posted:

I'd like to see his definition of encapsulation for which this statement makes any sense at all.
Actually that point is pretty valid, a pattern of calls like thisObject.getSubObject().getOtherSubObject().performAction() is generally pretty bad, and it violates the conventional definition of encapsulation because objects aren't hiding their internals at all.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Plorkyeran posted:

Anyone who actually uses string.Empty deserves it.
why does it matter, they're both the same

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Janin posted:

yup
which city

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Ensign Expendable posted:

code:
public boolean isTrue(boolean bool)
{
    return !Boolean.toString(bool).length()==5;
}
Oh come on, that has to be a joke.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Factor Mystic posted:

This is just someone who's not used to version control
Arguably a horror.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
What? Why would you declare variables at the start of your scope? It adds extra lines and confusion.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Dicky B posted:

Because:
code:
void fun() {
  some_type foo;
  if(something) {
    // do something with foo
  }
  else {
    // don't do anything with foo
  }
  // end of function.
  // we may have paid for the construction of foo even though we didn't use it!
}
Not that I agree with declaring the variables at the top of scope, but this is the wrong reason. There's a difference between declaration and construction.

angrytech posted:

But why? Pretty much every cs class at my university teaches students to declare variables at the beginning of the function(obviously not loop counters and poo poo like that).
It's mainly just readability, I think. Things flow much more logically if you just make declarations as they are needed. Seeing a bunch of declarations at the top of the function do absolutely nothing but waste space, since you can't tell how or when they're being used without scanning the rest of the function.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
I guess I forgot about that. A horror indeed.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Munkeymon posted:

If you need access to an object in the finally block of a try, you have to declare it outside of the try, but you do not have to instantiate it outside the try.
An even simpler example is declaring a base type or interface and then instantiating it two different ways in an if/else
code:
IAnimal animal;
if (wantCat)
{
  animal = new Cat();
}
else
{
  animal = new Dog();
}
animal.MakeNoise();

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

Zombywuf posted:

Well, aside from the fact that your goon.getChildField() is unlikely to work there (goon is MySuperClass not MyChildClass), if you have child specific cloning behaviour you should have a virtual clone method on the superclass which would allow:
You're addressing a totally different design concern, the example obviously illustrates the intended point.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
code:
out
is a horror

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!

nielsm posted:

("C++ doesn't need garbage collection, because it doesn't produce garbage.")
This quote is ridiculous, C++ produces plenty of garbage that you need to clean up yourself.

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
Haha, worst binary search variable names ever. Also runs a comparer of unknown complexity 3 times per iteration...

Adbot
ADBOT LOVES YOU

Orzo
Sep 3, 2004

IT! IT is confusing! Say your goddamn pronouns!
There's no bug, it's by design...the variable is called 'maybe' because maybe it overflows, maybe it doesn't.

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