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
PrBacterio
Jul 19, 2000
I believe there's somewhat more to the C++11 standard than just those new to_string functions, right?

Adbot
ADBOT LOVES YOU

hobbesmaster
Jan 28, 2008

PrBacterio posted:

I believe there's somewhat more to the C++11 standard than just those new to_string functions, right?

Yes and MS is pretty good about supporting it in VS2010 and 2012.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Manslaughter posted:

Holy christ on a cracker

Aww, you found something I could have written just a couple of years ago. :3:

TheSkeletonMan
Feb 24, 2011

PrBacterio posted:

The same goes for C++ string handling, where it isn't even possible to convert a number into a string with standard C++ functions except by using a string stream. What ought to be a single line of code
C++ code:
std::string s = std::string( some_float_value );
thus becomes three or more:
C++ code:
std::ostringstream buffer;
buffer << some_float_value;
std::string s = buffer.str();
:gonk:

There's always boost::lexical_cast.

etcetera08
Sep 11, 2008

This isn't really a coding horror but it certainly belongs in this thread regardless. My data structures + algorithm design/analysis class this semester uses an awful book by Richard Neopolitan that has a killer gently caress up:




Fortunately none of the actual text has the misspelling/error but having it on every other page in the header might be even worse..

Opinion Haver
Apr 9, 2007

What're the odds that it was a bad spellcheck dictionary/a copyeditor that doesn't know the word 'intractability'?

etcetera08
Sep 11, 2008

Yeah, I'm sure that's what happened but if you're a copyeditor of an algorithms book and the word is strewn throughout the text you probably shouldn't gently caress that up.

Unless you're saying the odds are low, in which case.. I dunno.

Bunny Cuddlin
Dec 12, 2004
lol "traveling salesperson"

Opinion Haver
Apr 9, 2007

I'd buy an algorithms book that exclusively used female pronouns/names for algorithm descriptions throughout.

FamDav
Mar 29, 2008
It would be p awesome if the text misstated the NP-Complete version of the traveling salesman problem.

Optimus Prime Ribs
Jul 25, 2007

For a few hours I've been pulling my hair out over a C++ glitch that I introduced. I was storing a value in a char that was supposed to be an unsigned char and kept wondering why I was getting a 0 value when I shouldn't have been.
I am the coding horror. :suicide:

That Turkey Story
Mar 30, 2003

Bunny Cuddlin posted:

lol "traveling salesperson"

These are changing times.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
I received an eval copy of a data structures textbook that I was considering using for my class next spring. At first, it was great. Awesome topic order, good coverage of the material, well-written... until I flipped to a random page on lists and saw:

"Unlike the standard Java List interface, our list will start at index 1."

:gonk:

The whole book was tainted after that. Every algorithm that used that list interface had little +1s and -1s scattered all over it to correct for this stupid design decision.

How does an author not realize how stupid he's being when he has to write correction code like that?

How do other reviewers before publication time not say "What the gently caress are you doing?"

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Bunny Cuddlin posted:

lol "traveling salesperson"

I wonder how you'd make something like Hall's Marriage Theorem less gender-specific.

zokie
Feb 13, 2006

Out of many, Sweden
Datetime strings and what Internet Explorer thinks of them
code:
"2012-12-14 14:48" //Invalid
"2012/12-14 14:48" //Valid
"12-14-2012 14:48" //Valid
This is by design, I can't fathom why.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

I'd put money on it being some kind of ancient Excel or office compatibility issue.

Bunny Cuddlin
Dec 12, 2004

That Turkey Story posted:

These are changing times.

"SENIOR software developer is ageist. From now on your job title is Extensively Experienced Software Developer."

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Received this snippet from a customer who is still working in VB6:
code:
result = foo_get_status(0, 0)
MsgBox result
5
If foo_isready(0, 0) <> 1 Then
DoEvents
GoTo 5
Else
Position0 = foo_get_result(0, 0)
End If
I was unaware that VB6 even supported line numbers.

tef
May 30, 2004

-> some l-system crap ->
if you number the lines, you can get line numbers in error messaged by using the semidocumented 'Erl' variable. :eng99:

Zombywuf
Mar 29, 2008

It occurs to me that I never tried putting the line numbers out of order...

Polio Vax Scene
Apr 5, 2009



Use a negative number, jump out of the stack like a train off its rails

movax
Aug 30, 2008

Not really a horror, but buried deep in a legacy BIOS AGESA module...

code:
call StartupDCT_D   ;yeaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!
:downs: I think this pre-dates that Caruso meme, but I've found other weird poo poo in here as well.

uncleTomOfFinland
May 25, 2008

That Turkey Story posted:

These are changing times.

In my database theory class the lecturer had to point out one of the textbook examples that involved modeling family relations wasn't really compatible with our same-sex civil partnership laws..

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

uncleTomOfFinland posted:

In my database theory class the lecturer had to point out one of the textbook examples that involved modeling family relations wasn't really compatible with our same-sex civil partnership laws..

Seems like a good time to wheel this out again...

http://stackoverflow.com/questions/6163683/cycles-in-family-tree-software

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off
Ok, so this guy is a prick. I told him to take his java code and turn it into c# code, because we're a c# shop. And he said "<bosses name> has been riding me, and he said i could write it in java code", or something like that. Kinda pissed me off, but ok, can't over-rule the boss(at least not without talking to him first)
Next time I saw <bosses name> was at a meeting about the project.. This was also the first time i got to actually see idiot's code. He had put everything in a single 3000 line file. Not only that, but he had written everything in functions (or methods if you wanna get technically correct). Each method dealt with one line. And yeah, each method had code in it that parsed the given line. But it just printed out to the console. It didn't do anything with the result of that parsing, or decoding. really. This is what he had:
code:
void ParseLineType1(string Line){
    String field1 = line.substring(0,8)
    Console.WriteLine(field1)
    String field2 = line.substring(8,10)
    Console.WriteLine(field2)
    ...
    ...repeat for every field in line
    ...
}

...Repeat for every line type (about 3 thousand lines of code)
He had the actual field names instead of field1, field2 etc...and the actual line types for method names. That's not the point, it's that his code didn't do anything. It just printed out stuff to the screen.

This stuff has to go in a database, not to the screen. And besides, some lines are gonna have info that other lines need if you want to put them in a database, and link them together. For instance link the merchantId with the various authorization records. I knew this, and I hadn't even read the spec really. I kind of scanned over it. It's just common sense. There was no way his solution was gonna work, and he'd basically wasted his time.

I was more diplomatic than that though. I said look, you need to break this out into objects, and you're gonna want to use a base class, an abstract base class really. You might as well write it in c#. But it was as if he had no idea why he would need to do that. He really pushed back.

Oh, and the fact that he has a 3000 line code file that was not auto generated. If you find yourself in the middle of typing up a 3000 line file, you should probably rethink your career choice.

Wow, sorry this is so long. But this guy really got under my skin. I've had a real breakthrough recently, and realized I need to stop coddling these guys. If I can tell they're not gonna work out after a week, I need to fire them (I don't really have the power to fire anyone, but the owner loves me, and trusts my opinion implicitly). It really wastes everyone's time to let them linger on

This was not the end of this guy, but I can assure you it has ended now. We have a new rule in my office. If you have a project with a 3000 line code file in it that was not auto-generated, you are fired. I have more about this guy if anyone cares.

.

bucketmouse
Aug 16, 2004

we con-trol the ho-ri-zon-tal
we con-trol the verrr-ti-cal
e: ^ holy crap

uncleTomOfFinland posted:

In my database theory class the lecturer had to point out one of the textbook examples that involved modeling family relations wasn't really compatible with our same-sex civil partnership laws..

Ours did too and we had to model an address book that was compatible.

http://qntm.org/gay has a funny take on the whole situation and how much of a hassle it is to implement correctly.

bucketmouse fucked around with this message at 01:35 on Dec 16, 2012

Posting Principle
Dec 10, 2011

by Ralp

Jen heir rick posted:

I have more about this guy if anyone cares.

Please share more :pray:

corgski
Feb 6, 2007

Silly goose, you're here forever.


The horror there is that the LDS church has created the specification for the most commonly used genealogy format, and purposefully crippled it to fit their moral standards.

awesmoe
Nov 30, 2005

Pillbug

Jen heir rick posted:

This was not the end of this guy, but I can assure you it has ended now. We have a new rule in my office. If you have a project with a 3000 line code file in it that was not auto-generated, you are fired. I have more about this guy if anyone cares.

What's wrong with 3k line files? If you're looking at two different pieces of code at once,you're going to have to open another view(/window/split/tab) for the second piece. Why does it matter whether the code is 3k lines away or 10k lines away, or whether it's in a different file? (Unless you never learned to use your editor, I guess)

Yes longer files can be annoying and can be a code smell, but seriously, firing people for 3000 line files? That's a management horror right there.

zeekner
Jul 14, 2007

awesmoe posted:

What's wrong with 3k line files? If you're looking at two different pieces of code at once,you're going to have to open another view(/window/split/tab) for the second piece. Why does it matter whether the code is 3k lines away or 10k lines away, or whether it's in a different file? (Unless you never learned to use your editor, I guess)

Yes longer files can be annoying and can be a code smell, but seriously, firing people for 3000 line files? That's a management horror right there.

There are always exceptions and cases where 3k isn't that bad, and I would give a little leeway depending on the language. I recently refactored an 1800 line monstrosity into 3 manageable classes, and that significantly improved readability.

If anyone doesn't feel the need to rework something that ugly, then I start questioning their capabilities. If I worked on a team where that was the norm, I'd look for another job.

awesmoe
Nov 30, 2005

Pillbug

Geekner posted:

There are always exceptions and cases where 3k isn't that bad, and I would give a little leeway depending on the language. I recently refactored an 1800 line monstrosity into 3 manageable classes, and that significantly improved readability.

If anyone doesn't feel the need to rework something that ugly, then I start questioning their capabilities. If I worked on a team where that was the norm, I'd look for another job.
I'm not convinced that if you took the files you wrote your 3 new manageable classes in, and concatenated them together into one big long file, you would have affected readability in any major way (except making it harder to navigate your project outside your IDE).

It's not like I write gigantic files recreationally, and I'm not claiming long files are strictly superior to short ones or anything. My main point is that messiness (not file length) is what matters when it comes to refactoring. I dislike the dogmatic attitude that guy had - and if I had a manager who made decrees like the above, I'd sigh heavily and start daydreaming about writing my code with line 2999 being #include "filename2.cpp"

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

awesmoe posted:

What's wrong with 3k line files? If you're looking at two different pieces of code at once,you're going to have to open another view(/window/split/tab) for the second piece. Why does it matter whether the code is 3k lines away or 10k lines away, or whether it's in a different file? (Unless you never learned to use your editor, I guess)

Yes longer files can be annoying and can be a code smell, but seriously, firing people for 3000 line files? That's a management horror right there.

I knew someone would fuckin' say this, so I'd just like to note that
1. I will make an exception for people who come to me first and I approve of their approach
2. They can always split there code into partial classes to get around the rule
3. I was kidding, there is no such rule

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!



This person is an intern, right? Like, they've never really programmed before. Give me that at least.

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

awesmoe posted:


...My main point is that messiness (not file length) is what matters when it comes to refactoring. I dislike the dogmatic attitude that guy had - and if I had a manager who made decrees like the above, I'd sigh heavily and start daydreaming about writing my code with line 2999 being #include "filename2.cpp"

Actually his code was not messy at all. Sure he had hundreds of methods that all did basically the same thing, but it was very neatly typed, indented and even commented in places. My point was that his code was not very extensible. I asked him how he planned to proceed with the project and he had no idea. I knew how he could proceed, but he wouldn't listen to me. And it took me and a coworker and my/his boss telling him to, before he agreed to.

And if it's so easy to navigate around one giant file in modern IDEs, why not put all of your classes in one file. Why this arbitrary practice of placing different classes in different files? Just shove em all in one big file. Saves a lot of time not having to right click->new class. Right?

Oh and in case you missed it the first time. I was kidding. It was a joke.

*edit* I think I'm gonna start coding this way, it really would be convenient!!

Jen heir rick fucked around with this message at 23:56 on Dec 15, 2012

pigdog
Apr 23, 2004

by Smythe

awesmoe posted:

I'm not convinced that if you took the files you wrote your 3 new manageable classes in, and concatenated them together into one big long file, you would have affected readability in any major way (except making it harder to navigate your project outside your IDE).
It's not just about readability. A 3000 line class most likely does all sorts of things from knitting to dishes, and is far from complying with the single responsibility principle. Which makes the class hard to mock and test, among other things such as comprehension and confidence in its behavior. It probably also has a ton of repeating, copy-pasted code with its obvious drawbacks.

awesmoe
Nov 30, 2005

Pillbug

Jen heir rick posted:

I knew someone would fuckin' say this, so I'd just like to note that
1. I will make an exception for people who come to me first and I approve of their approach
2. They can always split there code into partial classes to get around the rule
3. I was kidding, there is no such rule
1. You haven't explained why it's an approach that needs special-case approval
2. So it's literally dogma, rather than an objection based on a short-files-enforce-reduced-class-length-to-maximize-responsibility-splitting argument (for example). Cool.
3. Well I guess if you're not actually doing what you said you were doing, it matters a lot less!

Jen heir rick posted:

Actually his code was not messy at all. Sure he had hundreds of methods that all did basically the same thing, but it was very neatly typed, indented and even commented in places. My point was that his code was not very extensible. I asked him how he planned to proceed with the project and he had no idea. I knew how he could proceed, but he wouldn't listen to me. And it took me and a coworker and my/his boss telling him to, before he agreed to.
I was replying to the guy who said "I refactored a long file into 3 short classes".
In your example, you weren't refactoring his code, you were binning his lovely code. Guess what? If he'd split it into six 500 line files you would still have binned it because it would still have been lovely! (I'm not arguing the shittyness at all, it all sounds very stupid.)

pigdog posted:

It's not just about readability. A 3000 line class most likely ...

Maybe - probably! - but we're talking about files not classes.

awesmoe fucked around with this message at 00:16 on Dec 16, 2012

nielsm
Jun 1, 2009



awesmoe posted:

Maybe - probably! - but we're talking about files not classes.

This was Java. You know, where one file is typically one class.

Wozbo
Jul 5, 2010

awesmoe posted:

Maybe - probably! - but we're talking about files not classes.

I'm quoting this because that's a bullshit response and you know it. The whole point of this discussion is that someone didn't go "Wait, do I really need to manually do all of this?"

As for 3k line files (I swear I've got to be falling for some sort of trolling here), honestly, there's a point at which a code "thing" is too big and it becomes a hassle to maintain. I mean, hell, that's why we have the term "spaghetti code." Even still, its so much easier to maintain a normalized code base instead of having some gigantic monster doing all the work from one god file. Its also easier to do code reviews and to keep management of said code under wraps. I would not like to have everyone working on one monster file in my svn repo.

Doctor w-rw-rw-
Jun 24, 2008

awesmoe posted:

Yes longer files can be annoying and can be a code smell, but seriously, firing people for 3000 line files? That's a management horror right there.

It may not be a valid metric (in the sense that it's a measurable line to cross), but it sure as hell is a good heuristic for determining lovely programmers.

Adbot
ADBOT LOVES YOU

zeekner
Jul 14, 2007


It isn't about some bullshit dogma, but the fact that you think gigantic source files are A-OK and unrelated classes should share a source file for convenience. Get a proper IDE that can jump between source files by reference, and use some loving subfolders.

Not everyone who manages code is some dogma-sperg, 3k is just a point where 99% of cases you have someone doing something stupid. I'm willing to bet you aren't in the 1%.

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