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
Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.

ErIog posted:

Well then go do that. Go give Notch your resume. Make your own awesome super-well-coded game that nobody will ever want to play.
This is completely absurd. You can't honestly believe that the only options are rushed-to-market-and-successful and well-coded-and-unplayed.

Adbot
ADBOT LOVES YOU

Scaevolus
Apr 16, 2007

When I posted that code all I hoped for was a few "heh"s... not this. :smith:

ErIog
Jul 11, 2001

:nsacloud:

Mustach posted:

This is completely absurd. You can't honestly believe that the only options are rushed-to-market-and-successful and well-coded-and-unplayed.

You're right. I don't, which is why I didn't say that. I was only trying to state that game design and coding practices do not correlate in the way that people in this thread vehemently assume they correlate. There's lots of really well-coded games that nobody buys or aren't good, and there's lots of games filled with abominable code like Minecraft that sell a million copies that people seem to like. It's impossible to make any kind of value judgment about whether or not a game is good based on its code, and its also impossible to make a semi-related judgment about whether or not a game will be a commercial success based on its code or whether or not it is good.

Zombywuf posted:

Once again you fail to notice you are posting in the thread where we rip on lovely code and the people who write it.

I agree with the first part, but I don't see why it needs to extend to ripping on the people. Most of the people who have ever posted in this thread have freely admitted to writing their own lovely code from time to time. Some people have posted horrors they themselves created in this thread. The software this forum runs on has been known to contain a coding horror or two in its day.

If we're going to rip on any person that's ever written lovely code or any product that contains lovely code then it's pretty much going to be that anyone who has ever touched a computer is an untalented jerk that never should have been born, and nobody should really use a computer because every single piece of software ever sold is shovelware because the person who created it might have made a mistake during its creation.

Standish posted:

So this is why all the Minecraft threads have titles about bans/probations, thanks for clearing that up.

I don't play Minecraft, have never posted in any Minecraft thread, and I believe this is probably the first conversation I've ever gotten into about Minecraft.

I didn't have any problem with people criticizing the code when they were criticizing the code. I only started arguing when it spun into people's bullshit notions about whether or not they thought Minecraft was worth buying or selling or whether or not Notch should be successful; both of which are completely unrelated to the loving code.

I agree with your general sentiment that this derail has produced lots of stupidity and that it shouldn't go on any longer, and so I promise not to post anything related to Minecraft in this thread again. I think it'll be pretty easy since I don't plan to play Minecraft or disassemble Minecraft's code.

ErIog fucked around with this message at 18:01 on Jan 8, 2011

mr_jim
Oct 30, 2006

OUT OF THE DARK

Jesus Christ. Just loving drop it.

Zombywuf
Mar 29, 2008

Coding horrors: let's all post about our feelings

NotShadowStar
Sep 20, 2000
I don't know how some lego like retro styled world game like thing (I have tried Minecraft for 5 minutes) causes such fervor in so many people.

tef
May 30, 2004

-> some l-system crap ->
minecraft raus

tef
May 30, 2004

-> some l-system crap ->

ErIog posted:

If we're going to rip on any person that's ever written lovely code or any product that contains lovely code then it's pretty much going to be that anyone who has ever touched a computer is an untalented jerk that never should have been born, and nobody should really use a computer because every single piece of software ever sold is shovelware because the person who created it might have made a mistake during its creation.

all programmers are terrible and should be rounded up and shot :colbert:

The Reaganomicon
Oct 14, 2010

by Lowtax

tef posted:

all programmers are terrible and should be rounded up and shot :colbert:

         this, but unironically
                      \

Outlaw Programmer
Jan 1, 2008
Will Code For Food

ErIog posted:

...and its also impossible to make a semi-related judgment about whether or not a game will be a commercial success based on its code or whether or not it is good...

I think this is an important point probably and the crux of this thread. Coding horrors are NOT merely superficial nuisances for us programmers, they are directly responsible for bad software that doesn't work. The fact that Minecraft's code is a sloppy mess IS directly related to how buggy it is. This goes for all software.

At my current company, we have a guy that likes to write code like this:

code:
String optionA = null;

if (userOverrideA == null) {
    if (moduleDefaultA == null) {
        if (globalDefaultA != null) {
            optionA = globalDefaultA;
        }   
    } else {
        resultA = moduleDefaultA;
    }
} else {
    resultA = userOverrideA;
}

/* literally copy and paste for options B, C, D... */
During code review, I point out that you can do the same thing with chaining the if statements, instead of nesting them. You can also factor this out into a separate method and have one general way of choosing the appropriate option. The other developer will get offended and say that code reviews are only for finding bugs, not for criticizing "style."

Flash forward to 2 weeks later where there are 10 pages of code just to assign a few variables and the other developer is begging for help because there's a bug. Again, the other developer will refuse to refactor or clean up and just wants to slap a band-aid on this thing.

You can't tell if a product will be a commercial success by looking at its code, but you can get a pretty good idea on whether or not the thing will work!

P.S. This was my suggested refactoring, which of course got ignored:

code:
private static String getValue(String userValue, String moduleDefault, String globalDefault) {
    
    return userValue     != null ? userValue :
           moduleDefault != null ? moduleDefault :
           globalDefault != null ? globalDefault :
                                   null;
}

String optionA = getValue(userOverideA, moduleDefaultA, globalDefaultA);

Brecht
Nov 7, 2009

Outlaw Programmer posted:

code:
String optionA = null;

if (userOverrideA == null) {
    if (moduleDefaultA == null) {
        if (globalDefaultA != null) {
            optionA = globalDefaultA;
        }   
    } else {
        resultA = moduleDefaultA;
    }
} else {
    resultA = userOverrideA;
}

/* literally copy and paste for options B, C, D... */
That's pretty bad, and code reviews are definitely about making meaningful style (actually this isn't even style, it's flow control) fixes in addition to finding bugs, but this

quote:

code:
private static String getValue(String userValue, String moduleDefault, String globalDefault) {
    
    return userValue     != null ? userValue :
           moduleDefault != null ? moduleDefault :
           globalDefault != null ? globalDefault :
                                   null;
}

String optionA = getValue(userOverideA, moduleDefaultA, globalDefaultA);
is only marginally better. Don't nest the ternary operator.
code:
string foo(string a, string b, string c)
{
    if a {
        return a;
    } else if b {
        return b;
    } else if c {
        return c;
    } else {
        return "gently caress all y'all";
    }
}

Brecht fucked around with this message at 01:26 on Jan 9, 2011

Qwertycoatl
Dec 31, 2008

If that's C#, you could have
code:
private static String getValue(String userValue, String moduleDefault, String globalDefault) {
    return userValue ?? moduleDefault ?? globalDefault;
}

HIERARCHY OF WEEDZ
Aug 1, 2005

Outlaw Programmer posted:

code:
private static String getValue(String userValue, String moduleDefault, String globalDefault) {
    
    return userValue     != null ? userValue :
           moduleDefault != null ? moduleDefault :
           globalDefault != null ? globalDefault :
                                   null;
}

String optionA = getValue(userOverideA, moduleDefaultA, globalDefaultA);

I would have ignored you too. That's a really awful way of describing what amounts to a coalescing of values.

TOO SCSI FOR MY CAT
Oct 12, 2008

this is what happens when you take UI design away from engineers and give it to a bunch of hipster art student "designers"

Brecht posted:

That's pretty bad, and code reviews are definitely about making meaningful style (actually this isn't even style, it's flow control) fixes in addition to finding bugs, but this

is only marginally better. Don't nest the ternary operator.
You don't need 'else' when the code is returning.


code:
private static String getValue(String userValue, String moduleDefault, String globalDefault) {
    if (userValue != null) return userValue;
    if (moduleDefault != null) return moduleDefault;
    return globalDefault;
}

Outlaw Programmer
Jan 1, 2008
Will Code For Food
The main point was that there exists an effective way to choose options that doesn't involve copy-and-pasting 10 lines of code for each variable. Hell, I would have been happy if he just moved his original code and moved it into a single method. The reason he didn't, and also the reason why I try to avoid if-elseif-else constructs, is that he started doing things like this:

code:
    if a {
        globalState = false; // each switch set different variable
        return a;
    } else if b {
        return b;
    } else if c {
        return c;
    } else {
        return "gently caress all y'all";
    }
Once he started mixing the tasks of "choosing options" with "setting program state," he very quickly got tangled in a spider web of code. It's very tempting to use the above construct like that, which is why I'd rather have this:

code:
    // step 1
    String value = a != null ? a :
                   b != null ? b :
                   c != null ? c :
                               "gently caress all y'all";
    // step 2
    if( "a".equals(value) )
        globalSideEffect = false;
Now we're really getting into stylistic differences and I'd accept if-else stuff if it's sensible, like everyone's post has been so far. I actually think the chained (not nested!) ternary stuff is more readable because all the conditions are on the left, and the results are on the right, instead of:

condition
result
condition
result

raminasi
Jan 25, 2005

a last drink with no ice
Yeah I don't get the hate for ternary chaining, it's easily the most readable way for me to understand what's going on in that kind of situation.

Zhentar
Sep 28, 2003

Brilliant Master Genius

Brecht posted:

code reviews are definitely about making meaningful style (actually this isn't even style, it's flow control) fixes in addition to finding bugs,

I'd even go so far as to say code reviews are about finding bugs in addition to enforcing good style.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Zhentar: that and increasing the bus-factor of projects.

Brecht
Nov 7, 2009

Janin posted:

You don't need 'else' when the code is returning.
Yeah that's true. This is better still.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Internet Janitor posted:

Zhentar: that and increasing the bus-factor of projects.

I'm guessing on some teams it's the short bus-factor.

Zombywuf
Mar 29, 2008

A habit my workplace has grown out of thankfully is increasing the bus factor of projects by having most people working on several projects at a time. Thus no-one really had their head wrapped around any project giving them all a bus factor of 0.

Scaevolus
Apr 16, 2007

A bus factor of zero means no one knows how the codebase works.

edit: :downs:

Scaevolus fucked around with this message at 20:08 on Jan 10, 2011

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Yes, that is what he said.

BigRedDot
Mar 6, 2008

Speaking of the bus factor, in the lab I work the powers that be make it a point to never have more than one person work on any given project and to never do code reviews. Metaphorically we are all encased in carbonite silos where we are encouraged to reinvent seven sided wheels over, and over.

Fake edit: and this software goes on multi-billion dollar navy platforms, your tax dollars at work!

the talent deficit
Dec 20, 2003

self-deprecation is a very british trait, and problems can arise when the british attempt to do so with a foreign culture





quote:

Somewhat typical of PHP’s API, there are actually thirteen different built-in array sorting functions. The manual page for sort says that most of those functions use quicksort, which means they’re all unstable. Prior to version 4.1.0 some of the sorting algorithms were stable, but that was changed for “efficiency reasons”. (It seems that the usort function was previously implemented as a bubble sort, the only case of that I’ve ever seen in a serious production language)

From here

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
http://thedailywtf.com/Articles/Confessions-The-Shopping-Cart.aspx

quote:

The project called for a shopping cart and, after reading a 30 minute "getting started" guide on SQL, I created my first database. I figured a Shopping Cart is a logical unit of data, and as such deserving of its own table. And since each Shopper had their own shopping cart, they should also have their own Shopping Cart table.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
I went through the same chain of logic when I was trying to write a game. "How can I make a separate table for each player?"

Luckily I actually asked someone who knew their rear end from a hole in the ground about it.

spiritual bypass
Feb 19, 2008

Grimey Drawer

Well you see I wanted the database to have some warehousing features...

Milotic
Mar 4, 2009

9CL apologist
Slippery Tilde

Ryouga Inverse posted:

I went through the same chain of logic when I was trying to write a game. "How can I make a separate table for each player?"

Luckily I actually asked someone who knew their rear end from a hole in the ground about it.

This is pretty much how Screwturn Wiki works. Each wiki site creates its own set of tables in the database, prepended with the wiki name. Most tables don't have primary keys, including the page version history tables.

I sometimes wonder which is worse - that, default SharePoint wikis or SharePoint wikis extended by KwizCom.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Alternatively, consider using the WCF Integration Pack for Enterprise Library. It contains classes that you can use directly to enable storage of and access to the container in WCF applications, and it can be used to automatically populate dependencies in your classes.


Forward-thinking documentation.

POKEMAN SAM
Jul 8, 2004

Coding horrors: Proggit/HackerNews reposts

tef
May 30, 2004

-> some l-system crap ->
code:
int a;
int pi = 3.14;
int area;
int main()
{
    cout << "Input the radius of the circle ";
    cin >> a;

    a *= a *= pi >> area;

    cout << "The area is " << area;


}
this code is perfect in every way :3:

http://stackoverflow.com/questions/4700508/why-does-the-area-come-back-as-0

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
C++'s fault for overloading bit shifts in iostream, giving this poor guy two different assignment operators to choose from seemingly arbitrarily (because one of them is completely arbitrary). The other two errors are very forgivable.

I guess what I'm saying is why shouldn't he expect the bit shift by area to be an assignment? Now I just feel bad for him. He's not the problem here. His language has failed him.

tef
May 30, 2004

-> some l-system crap ->
and three is a pretty good value for pi

NotShadowStar
Sep 20, 2000

pokeyman posted:

C++'s fault for overloading bit shifts in iostream, giving this poor guy two different assignment operators to choose from seemingly arbitrarily (because one of them is completely arbitrary). The other two errors are very forgivable.

I guess what I'm saying is why shouldn't he expect the bit shift by area to be an assignment? Now I just feel bad for him. He's not the problem here. His language has failed him.

Yeah I don't really blame him, he looks like a high school student trying to learn something and got caught in the trap of 'C++ IN TWENTY ONE DAYS'. C++ is a mess of a language even to experienced programmers, someone who is completely new would make these kind of mistakes because there's no logical distinctions.

And of course the dripping pit of Aspergers, Stackoverflow, just rip into him instead of actually guiding him.

Dicky B
Mar 23, 2004

This must be the coding horrors equivalent of Slow News Day.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Sorry, but using int for PI is hilarious, and so is that usage of *=.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
:awesome:This code is so broken it's not even funny any more. For starters: Do you realize that cin >> ... (and cout << ...) is a very special case and << (and >>) mean something very different in about every other context, including in pi << area? You're lucky you get 0 though, you might as well get anything.



You know, instead of answering him.

Opinion Haver
Apr 9, 2007

Wheany posted:

:awesome:This code is so broken it's not even funny any more. For starters: Do you realize that cin >> ... (and cout << ...) is a very special case and << (and >>) mean something very different in about every other context, including in pi << area? You're lucky you get 0 though, you might as well get anything.



You know, instead of answering him.

I'm teaching a python class for nonprogrammers, and I've seen some pretty weird stuff (people using while foo: bar; break instead of if foo: bar). But they're not programmers.

Adbot
ADBOT LOVES YOU

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

yaoi prophet posted:

I'm teaching a python class for nonprogrammers, and I've seen some pretty weird stuff (people using while foo: bar; break instead of if foo: bar). But they're not programmers.

How many programmers you know regularly work on radius calculation programmes?

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