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
Opinion Haver
Apr 9, 2007

Jonnty posted:

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

That's the point I was making; that the people making fun of him in the comments are mean-spirited since this guy obviously isn't a programmer.

Adbot
ADBOT LOVES YOU

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

yaoi prophet posted:

That's the point I was making; that the people making fun of him in the comments are mean-spirited since this guy obviously isn't a programmer.

Oh sorry, I thought you were saying the opposite because posting on stackoverflow makes you a professional programmer or something. My mistake :)

zootm
Aug 8, 2006

We used to be better friends.

NotShadowStar posted:

And of course the dripping pit of Aspergers, Stackoverflow, just rip into him instead of actually guiding him.
My favorite instance of this form of nerd rage was in an IRC channel, where someone continually rked into a beginner's program's time complexity instead if helping the guy with his elementary syntax problem. The internet's supply of self-righteous arseholes is seemingly inexhaustible.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

zootm posted:

My favorite instance of this form of nerd rage was in an IRC channel, where someone continually rked into a beginner's program's time complexity instead if helping the guy with his elementary syntax problem. The internet's supply of self-righteous arseholes is seemingly inexhaustible.

It was said on a Starcraft forum but it holds true everywhere: People don't post on forums because they want to be helpful or to discuss things. They post on forums because they want to be right.

And what better way to be right than by making someone feel terrible for being wrong?

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Ryouga Inverse posted:

It was said on a Starcraft forum but it holds true everywhere: People don't post on forums because they want to be helpful or to discuss things. They post on forums because they want to be right.

And what better way to be right than by making someone feel terrible for being wrong?

I like that. I will use that quote in the future.

I find that if you don't want to be a douche, try to interpret other people's comments/questions in the most charitable way possible. For example, with the code under question, you could assume the guy is an idiot, or you could assume he's just ignorant.

Lysandus
Jun 21, 2010
code:
public int getItemId(int ID)
{
    return ID;
}
:psyduck:

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Lysandus: Placeholder for validation logic? Please? :(

NotShadowStar
Sep 20, 2000
Probably a typo or slip of the brain. Likely meant 'return _itemID' or some such.

Slow coding horror weeks!

Lysandus
Jun 21, 2010

Internet Janitor posted:

Lysandus: Placeholder for validation logic? Please? :(

It's existed for three versions of the software and there are no comments around it indicating it might be.

NotShadowStar posted:

Probably a typo or slip of the brain. Likely meant 'return _itemID' or some such.

Slow coding horror weeks!


Here's the best part. The only place it's used.
code:
for( Contact contact : contactVector)
{
    Log( "Adding contact with ID: ", getItemId( contact.getId() ) );
	        		
    //other processing stuff
}
If it was to have another use, I have yet to find it.

zeekner
Jul 14, 2007

code:
hd_quality = int(self.__settings__.getSetting( "hd_videos_download" ))
if ( hd_quality == 0 ):
       hd_quality = int(self.__settings__.getSetting( "hd_videos" ))
else:
       hd_quality -= 1
'getSetting' returns a boolean in this case, int() throws a invalid value error.

This breaks a major feature in XMBC, and has gone unnoticed for months because of differences in how major versions of python handle int(boolean).

Goat Bastard
Oct 20, 2004

Lysandus posted:

Here's the best part. The only place it's used.
code:
for( Contact contact : contactVector)
{
    Log( "Adding contact with ID: ", getItemId( contact.getId() ) );
	        		
    //other processing stuff
}
If it was to have another use, I have yet to find it.

I found one like this a while ago, I think some people just think in broken ways.

code:
findRecordById(this.getRecord().getId())
findRecordById makes a database call to find a record. getRecord is simple getter that returns the record, as you would expect. This was all over the place with different entities, and the person who wrote it looked at me like I was a cretin when I asked what the point was.

PIGEOTO
Sep 11, 2007

Recently for my degree, we had to participate in a 6-man group project to combine 3 different scripting languages (JS, perl, python) to produce some kind of product that could be pitched to our lecturers. We ended up choosing an online poker game that is run from a webpage, much like like a flash game but written in JS.

Our group comprised of me, my 2 housemates, a friend, and 2 other guys who none of us knew but had added themselves to our group on the student wiki. Fine, we weren't too bothered since we didn't really have any other people to take on. We were a little skeptical however since one of them has failed the year before and his previous scripting project had been written at the last minute and comprised of 300 lines of perl python and JS.

Anyway, they'd volunteered to write the Python side of the product which comprised of creating the actual rules and gameplay of our poker game. It would then send a JSON gamestate to the javascript via AJAX. They had been adamant throughout the project that things were going well and they were making good progress on the game, but when we finally came round to testing it, the python was completely broken and didn't at all resemble a poker game. Their code was absolutely atrocious to the point that it defies belief. There seemed to be an almost total lack of loops in favor of exhaustive enumeration using ifthenelse statements. Check this out;
code:
if (sblindplayer == 1)
	thisGame.player1.bet = thisGame.s_blind
	thisGame.player1.chipstack = thisGame.player1.chipstack - thisGame.s_blind
	thisGame.pot1 = thisGame.s_blind
elif (sblindplayer == 2)
	thisGame.player2.bet = thisGame.s_blind
	thisGame.player2.chipstack = thisGame.player2.chipstack - thisGame.s_blind
	thisGame.pot1 = thisGame.s_blind
elif (sblindplayer == 3)
	thisGame.player3.bet = thisGame.s_blind
	thisGame.player3.chipstack = thisGame.player3.chipstack - thisGame.s_blind
	thisGame.pot1 = thisGame.s_blind
elif (sblindplayer == 4)
	thisGame.player4.bet = thisGame.s_blind
	thisGame.player4.chipstack = thisGame.player4.chipstack - thisGame.s_blind
	thisGame.pot1 = thisGame.s_blind
elif (sblindplayer == 5)
	thisGame.player5.bet = thisGame.s_blind
	thisGame.player5.chipstack = thisGame.player5.chipstack - thisGame.s_blind
	thisGame.pot1 = thisGame.s_blind
elif (sblindplayer == 6)
	thisGame.player6.bet = thisGame.s_blind
	thisGame.player6.chipstack = thisGame.player6.chipstack - thisGame.s_blind
	thisGame.pot1 = thisGame.s_blind
# small blind in! Next, the big blind
This is where they take the small blind from the current player's stack and place it into the pot. Instead of opting to have an array of players and simply writing out several lines of assignment, they have each player stored in a single variable each and copy the exact same code 6 times. You might be thinking "oh well it's only 6 players, what's the big deal?". The big deal is that they don't stop enumerating with the players, they do this for everything, including the cards in the deck (yes, there is 52 lines where they initialize 52 different card variables). Their shuffling method is 52 lines where they set all of the cards to 0 (The cards are booleans based on whether they are still in the deck or not, at least that's what I presume). And yes, the exhaustive enumeration hasn't stopped here;
code:
while (found == 0):
	cardnumber = random.randint(1,52)
	if (cardnumber == 1):
		if (self.card1 == 0):
			self.card1 = 1
			found = 1
	elif (cardnumber == 2):
		if (self.card2 == 0):
			self.card2 = 1
			found = 1
...
This is how they shuffle the cards. Rather, the deck stays the same, they just draw a card entirely at random and check if it is in the deck (lol). If not, pick another card. So you could potentially have a very long loop with a string of cards being picked that are not in the deck. Not only that, but the above pasted code below line 6 is repeated for every single card in the deck. urgghghghghghghgh

In total the entire python code, which was simply a game of poker, amounted to over 1200 lines. I learned a good lesson here however, do it all yourself.

PIGEOTO fucked around with this message at 04:56 on Jan 19, 2011

NotShadowStar
Sep 20, 2000

quote:

3 different scripting languages (JS, perl, python) to produce some kind of product that could be pitched to our lecturers

Real horror found. What the gently caress. Javascript for client UI and you need just one language for a server. Tying together two languages just for a server is madness and stupid.

quote:

I learned a good lesson here however, do it all yourself.

That's a good way on getting burned out in life. I'll tell you that I learned this far later than I should have. What you the other group members should do is go to the professor and explain that the other people were promising but not actually delivering, and what they are delivering is unworkable; but since they weren't working with you that you couldn't catch it.

PIGEOTO
Sep 11, 2007

NotShadowStar posted:

Real horror found. What the gently caress. Javascript for client UI and you need just one language for a server. Tying together two languages just for a server is madness and stupid.
Yeah, it wasn't actually our choice and I think pretty much everyone on the course and even the senior members of the department recognised that they didn't really work. JS and python maybe, but perl is just the odd kid who doesn't really fit in anywhere. Perl actually handled our login and lobby system (multiple games could be active at once and accessed from a game list). But again, perl really isn't neccessary at all. I think the point was more to do something neat with a really really unusual combination of languages.

quote:

That's a good way on getting burned out in life. I'll tell you that I learned this far later than I should have. What you the other group members should do is go to the professor and explain that the other people were promising but not actually delivering, and what they are delivering is unworkable; but since they weren't working with you that you couldn't catch it.
It's a bit late for us to complain about them since the coursework is in and demo'd, but even if it wasn't it's still only a coursework which we've probably gotten an ok mark for. We're not really too bothered about the situation since it's all part of the learning process and we're not really out to make enemies.

PIGEOTO fucked around with this message at 00:07 on Jan 19, 2011

Lysandus
Jun 21, 2010
I'm digging through a connection class for one of our internal apps and there is no handling for HTTP 401 responses from the server.


And by no handling I mean the entire app crashes if the server returns a 401.

PalmTreeFun
Apr 25, 2010

*toot*

PIGEOTO posted:

terrible poker horror

I did something like this when programming my first game ever. Back when I was 13. Except it was a platformer, and I didn't know what arrays were for, so I did that, and there were only 9 platforms allowed at any one time. I gave up because my program eventually became such a glitchy mess that teenager me didn't know how to debug it (I had a bug where damaging one enemy once would cause all the others to take tons of damage at once or die), but it was a fantastic learning experience. :v:

That said, this guy has had previous programming classes. I don't mean to be condescending to him, but come on. Arrays and loops are some of the first things you learn about in programming, and if he's not new at this and taking classes, that's just :psyboom:.

PIGEOTO
Sep 11, 2007

PalmTreeFun posted:

I did something like this when programming my first game ever. Back when I was 13. Except it was a platformer, and I didn't know what arrays were for, so I did that, and there were only 9 platforms allowed at any one time. I gave up because my program eventually became such a glitchy mess that teenager me didn't know how to debug it (I had a bug where damaging one enemy once would cause all the others to take tons of damage at once or die), but it was a fantastic learning experience. :v:

That said, this guy has had previous programming classes. I don't mean to be condescending to him, but come on. Arrays and loops are some of the first things you learn about in programming, and if he's not new at this and taking classes, that's just :psyboom:.
Yeah it is pretty amazing, but it's not an uncommon occurence. I'm lucky enough to be in one of the better unis in my country for CS which means I'm around a lot of really smart people. I've seen code from other unis and really, this exhaustive enumeration example is pale in comparison to the garbage that some people can output. It's sometimes hard to give advice because a lot of people will get offended because they don't see why their solution, which technically 'works', should be criticized. You know, the old "I don't care, just tell me how to fix it" when you're staring at god knows how many lines of indecipherable trash. The worst thing is that these people graduate with the absolute minimum knowledge of programming and are probably going to be able to hold down a decent programming job. That's the IT industry though, this thread is a great example of the amount of cowboys out there.

PIGEOTO fucked around with this message at 00:24 on Jan 21, 2011

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Found a routine today that assigns a waybill number for a certain shipping company. You would think that it'd be easy; connect to the shipping company via API, grab a waybill number, record/relate it, and move on. Apparently the first step is impossible because the shipping company can't definitively determine the status of waybill number at assignment, it has to clear their system after 24 hours.

Instead we're assigned ranges of shipping numbers that are 'ours' in the format of <char>12345, usually from 0-9999. This part is the horror. The previous guy made a proc that basically goes 'WayBillNo = <char> + Substring(WaybillsPrimaryKey,2,5)' after inserting each waybill registration. For those not following at home the horrors are:

- Every time the 'range' changes you have to manually increment the primary key to match the new range. So if the new range was 500-15000 you'd have to make sure the next PK inserted is x00500.
- Every time the <char> changes (which it does every time the range does) you have to change the stored proc's hardcoded value of <char>
- Because of the first part the primary key will grow unnaturally fast as you're always jumping to the next thousand/ten thousand/hundred thousand after a range change.
- The best part, related to the above: the whole thing will fail as soon the primary key reaches the next significant digit (e.g. moving from 10,000 to 100,000, 100,000 to 1,000,000, etc.) because the substring call doesn't care how long the thing is (there's a convert(varchar) I left out of the above for clarity).


I wonder how many other ticking time bombs like this waiting to be discovered... I mentioned it to a coworker and he just smiled and said "job security!"

EDIT-bonus points to whoever works in logistics and can identify the shipping company based on the structure of their waybill numbers

EDIT EDIT-It gets better; he's storing the result WayBillNo as a string in a varchar column. The column's defined size is varchar(6); as soon as the numbers pass 5 digits it would have broke there too.

Scaramouche fucked around with this message at 00:58 on Jan 21, 2011

TasteMyHouse
Dec 21, 2006
I don't know if this qualifies as a HORROR, but it really irked me.


I'm taking a Digital Signal processing lab, and we use C to program a Blackfin 535 emulator (one of these). On Friday, we ran through a basic familiarize-yourself-with-the-development-environment sort of lab.

Part of it was compiling and running some sample code, that looked something like this...

code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>



int a[20]={/*twenty ints*/};
int b[20]={/*twenty different ints*/};
int c[20]={/*twenty more ints*/};
const int N=20;

int a_dot_b( int *a, int *b )
{
    int i;
    int output = 0.0;

    for( i=0; i<N; i++ ) 
    {
		output += ( a[i] * b[i] );
	}

    return( output );
}



int a_dot_c( int *a, int *c )
{
    int i;
    int output = 0.0;

    for( i=0; i<N; i++ )
    {
		output += ( a[i] * c[i] );
	}

    return( output );
}

void main()
{
	int i;
	int result[2] = {0};
    
    result[0] = a_dot_b( a, b );
    result[1] = a_dot_c( a, c );
    

    for( i=0; i<2; i++ ) 
    {
		printf( "Dot product [%d] = %d\n", i, result[i] );
	}
}

Two functions, utterly identical except for the variable names.

Also int output=0.0;? whats that about?

I also cannot figure out where math.h is used.

When I asked the TA he condescendingly told me that obviously they wouldn't make two functions that did the same thing, and to check more carefully. When I showed him line by line that they were identical, he said it was because they were trying to be less confusing. Personally, I felt this to be a LOT more confusing that just using 1 function, especially since I wasted 10 minutes checking, rechecking, running the functions with different inputs, and talking to the TA.

darkhand
Jan 18, 2010

This beard just won't do!
What is the point of
code:
int i;
...
for (i=0;i<N;i++)

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

darkhand posted:

What is the point of
code:
int i;
...
for (i=0;i<N;i++)

In ANSI C you can't declare the variable i inside the for loop.

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.
code:
return( output );
Despite being totally harmless, whenever I see a parenthesized return expression, I feel that it's a very telling instance of bad style. It's as though the author is afraid of the programming language, but has no interest in learning. Do they think that return will only return part of the expression unless it's parenthesized? Do they think the parentheses are mandatory? Even worse, do they think that return is a function?

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.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Mustach posted:

Despite being totally harmless, whenever I see a parenthesized return expression, I feel that it's a very telling instance of bad style.
I like adding extraneous parentheses to lines like return ((((m-1)/t)*t)*((((((m-1)/t)*t)+t)*10)/(t*2)))/10; since that looks better to me than having naked numbers/whatevers like in this example. Cosmetic.

Edit: But return(stuff); is just weird.

Malloc Voidstar fucked around with this message at 21:50 on Jan 23, 2011

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Mustach posted:

code:
return( output );
Do they think that return will only return part of the expression unless it's parenthesized?

Some C/C++ compilers used to do that*. return a + b would return a without adding b to it and debugging that a few times will create a strong habitual aversion to leaving off parentheses as well as leave a pile of your hair on the floor behind the chair.

*Borland 4.something? did back in the late 90s. I don't remember if they fixed it in 5, but maybe I had learned to never try it again.

Munkeymon fucked around with this message at 22:53 on Jan 23, 2011

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

Mustach posted:

Even worse, do they think that return is a function?

Clearly return is the continuation implicitly passed to the current function, and if C supported higher-order programming you'd be able to pass it as a parameter to other functions for continuation-passing-style programming. People who use parenthesis on return are just planning ahead to be future-compatible with FunctionalC.

HORATIO HORNBLOWER
Sep 21, 2002

no ambition,
no talent,
no chance

TasteMyHouse posted:

I don't know if this qualifies as a HORROR, but it really irked me.

void main() is always a horror.

a slime
Apr 11, 2005

HORATIO HORNBLOWER posted:

void main() is always a horror.

Not when you're programming a DSP...

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Outlaw Programmer posted:

The other developer will get offended and say that code reviews are only for finding bugs, not for criticizing "style."

That's a total bullshit attitude. We treat code reviews as an overall sanity check, which includes calling people out on bad/questionable stylistic choices. Luckily, I work on a small team and the boss is a hardass who will outright tell you to stop being a pussy if you complain about someone being "mean" in a code review.

I've gotten my rear end handed to me in code reviews, and I like to think that I came away having learned something as a result. I mean, some stuff is personal preference... I don't like the ternary operator, but I'm not going to insist that someone not use it unless it makes the code an unreadable shitpile.

dark_panda
Oct 25, 2004

TRex EaterofCars posted:

In ANSI C you can't declare the variable i inside the for loop.

You can according to C99, although compilers like gcc require you to explicitly enable C99 features.

Edison was a dick
Apr 3, 2010

direct current :roboluv: only

dark_panda posted:

You can according to C99, although compilers like gcc require you to explicitly enable C99 features.

I don't understand your point. ANSI C is not C99 and while C99 is becoming the standard, ANSI C is portable to compilers that don't support C99, so if you program for portability it is beneficial to pick the standard with the most compiler support.

That said, the reason for it being chosen is more likely that it was programmed by someone who learned C before C99 became common.

a slime
Apr 11, 2005

Or in this case probably because someone learned by example from someone who learned by example from someone who learned C before C99 became common

MrMoo
Sep 14, 2000

Edison was a dick posted:

I don't understand your point. ANSI C is not C99 and while C99 is becoming the standard, ANSI C is portable to compilers that don't support C99, so if you program for portability it is beneficial to pick the standard with the most compiler support.

C99 is ANSI C, along with C90 and C89. What am I missing?

http://en.wikipedia.org/wiki/ANSI_C


Similar pedant post of the day on Stackoverflow, "UTF-8 isn't guaranteed by the C++ standard so you shouldn't use it":

http://stackoverflow.com/questions/4766301/windows-console-and-qt-unicode-text/4769080#4769080

I deliberately use UTF-8 to gently caress over stupid MSVC users, I have no problem in MSVC 2010, OS X, Solaris or Red Hat. Just because Windows likes UCS2-LE internally doesn't mean you have to use it anywhere else.

MrMoo fucked around with this message at 15:08 on Jan 24, 2011

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!

MrMoo posted:

C99 is ANSI C, along with C90 and C89. What am I missing?

http://en.wikipedia.org/wiki/ANSI_C

quote:

C89
[snip]
This version of the language is often referred to as "ANSI C", or sometimes "C89" (to distinguish it from C99).
[snip]
C99
In March 2000, ANSI adopted the ISO/IEC 9899:1999 standard. This standard is commonly referred to as C99
So C99 has been adopted by ANSI as the current standard for the C Programming language, but it is not "ANSI C".

dark_panda
Oct 25, 2004

Jethro posted:

So C99 has been adopted by ANSI as the current standard for the C Programming language, but it is not "ANSI C".

Anyways, my point was that it's valid C according to C99 and that some people are used to seeing it these days. It's not "ANSI C", granted, I just meant that it's valid C now is all. Jeez.

Ogive
Dec 22, 2002

by Lowtax

Mustach posted:

code:
return( output );
Despite being totally harmless, whenever I see a parenthesized return expression, I feel that it's a very telling instance of bad style. It's as though the author is afraid of the programming language, but has no interest in learning. Do they think that return will only return part of the expression unless it's parenthesized? Do they think the parentheses are mandatory? Even worse, do they think that return is a function?

None of the above. Seriously, few people think they're anything but syntactic idioms.

Over the years, I've learned to let things like this slide. My boss got up on my rear end a bit at first about "if (x)" vs "if(x)", "return(x)" vs "return x", and so forth. (They're big on the bracketed returns, if you haven't guessed). The justification was that it was easier for humans to scan, and that justification even extends to their tab width selection. The coding standards doc has references, but I haven't checked them out.

Everyone has their coding peccadilloes -- for instance, despite my preference for "return x", I had a habit of putting brackets around unary operators, despite precedence. Letting the little things slide in exchange for having everyone on a team code in a consistent manner is a very good tradeoff -- one very much appreciated in the dark hours of the morning.

evensevenone
May 12, 2001
Glass is a solid.
Is there anyone in the world who upon seeing the words "ANSI C" would think "C99"?

MrMoo
Sep 14, 2000

Well I wouldn't jump to thinking C89 either.

Vanadium
Jan 8, 2005

gcc's -ansi gets you close enough to C89, though.

Adbot
ADBOT LOVES YOU

Opinion Haver
Apr 9, 2007

Tumblr lets users reblog/like posts they see on their dashboard. When you look at an individual post, it also shows you the last 50 or so 'notes' (reblogs, likes, and replies) on that post, not only by that user, but by all people who reblogged that post. Pretty interesting, right? Sounds like the sort of data you might want to visualize if you're into that sort of thing.

Well, you can't. There's no way, API or scraping, to get all the notes; you have to manually do XmlHttpRequests. And even then you can't get all of them because it likes repeating notes and at some point it gives you the same set of 50 over and over again. Fortunately, you can detect this because it gives you the same XHR url, but still. Ugh.

Bonus horror: your tumblr URL is username.tumblr.com. Usernames can begin or end with dashes. The grammar suggested by RFC 1035 for DNS doesn't allow that. So it's a crapshoot as to whether usernames that begin/end with dashes will actually work in any given program. And it's common to use dashes as a 'someone else got to this username before I did' thing.

Opinion Haver fucked around with this message at 19:31 on Jan 25, 2011

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