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
beuges
Jul 4, 2005
fluffy bunny butterfly broomstick

ninjeff posted:

This is the real coding horror.

At a previous job, I inherited a project with a couple of .cpp files being well over 15000 lines each... one class per file.

Adbot
ADBOT LOVES YOU

posting smiling
Jun 22, 2008

kalleth posted:

He's quite clearly an emacs user

Obviously. Emacs is the only editor next to which vim looks archaic.

TasteMyHouse
Dec 21, 2006
Arguing about text editors is the real horror.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

pokeyman posted:

For what it's worth, default Xcode behaviour is to throw everything in one folder, so you see tons of iOS/Mac apps that have no folder organization.

As for the lack of subclasses, I'm trying to picture an Objective-C project where no class has a superclass. It's an ugly picture.

Yeah, I know that. Sadly this is the way we got the Xcode project itself. The classes group has 200 objects in it, most of the files being independent .h/.m sets subclassing one of the AppKit components. Basically there's a component subclassed for every little bit of weird behavior, despite a lot of it being similar/generic enough that a handful of abstract components would make a huge dent in the class count.

Do they give out negative scores for code reuse?

Holy John
Apr 21, 2008
I don't know why (or even how) anyone would do this, but I've seen a lot of really hideous, inconsistent indenting in computer science class projects the past few years.
All the time, I see code that looks like this:
code:
public static void main(String[] args){
	<statement 1>
      <statement 2>
           <statement 3>
       <statement n>
    }
I just can't figure out how their code could ever end up like that. It's a complete nightmare to read. Usually they won't even line up their braces and they'll lose track of what level of indentation they're in.

MrMoo
Sep 14, 2000

Not lined up hints at different tab size, if it was stackoverflow, inane disinterest in effort is quite popular.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



ultramiraculous posted:

Yeah, I know that. Sadly this is the way we got the Xcode project itself. The classes group has 200 objects in it, most of the files being independent .h/.m sets subclassing one of the AppKit components. Basically there's a component subclassed for every little bit of weird behavior, despite a lot of it being similar/generic enough that a handful of abstract components would make a huge dent in the class count.

Do they give out negative scores for code reuse?

Sounds like they come from a completely different background. Generally you shouldn't even subclass AppKit classes (except a few things like Controllers), but use Delegates and Data Sources and such.

PrBacterio
Jul 19, 2000

MrMoo posted:

Not lined up hints at different tab size, if it was stackoverflow, inane disinterest in effort is quite popular.
Which is precisely the reason why mixing tabs and spaces is a horror :colbert:

Frozen Peach
Aug 25, 2004

garbage man from a garbage can
I've seen some IDEs that the alignment looks great when viewing the code in the IDE it was designed with, but then opening it in notepad or anything else just ruins all the formatting.

The worst I think was Borland C++Builder. Holy god trying to make that code look good in anything but it's own IDE was a nightmare.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
I love code which uses 4-space indents but replaces each set of 8 spaces with tabs. It's like they're going out of their way to maximize the chance of it looking it like.

Hammerite
Mar 9, 2007

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

Plorkyeran posted:

I love code which uses 4-space indents but replaces each set of 8 spaces with tabs. It's like they're going out of their way to maximize the chance of it looking it like.

haha what, who would do that instead of just making a tab 4 spaces?

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.

Plorkyeran posted:

I love code which uses 4-space indents but replaces each set of 8 spaces with tabs. It's like they're going out of their way to maximize the chance of it looking it like.
Something like this is the default behavior of emac's C mode. Using spaces for indentation? Once you hit that magic number of 8, it gets turned into a tab.

wellwhoopdedooo
Nov 23, 2007

Pound Trooper!
Hey, on average it saves 4 bits per indentation level per line. That's nothing to sneeze at.

Jerry Bindle
May 16, 2003
Embedded C Compilers are TRH. The ones I have to use are at least. It seems like every other day I find a crippling bug or limitation that at best I have to implement a goofy work around or at worst causes a project to stall. Today its function pointers. Wanna use a function pointer? Great! Just make sure it doesn't have any parameters, is assigned a value at declaration and never changed, and isn't called from both main-line and interrupt code.

EDIT: The instruction sets of the parts I'm using seem to have been designed for the ease of use of assembly programmers, and newer parts must support the same ISA but they've also added some really powerful instructions for C compilers to take advantage of. Years later, the C compilers still don't support these instructions :eng99:

Jerry Bindle fucked around with this message at 19:19 on Aug 5, 2011

mr_jim
Oct 30, 2006

OUT OF THE DARK

I use tabs for indenting, and spaces for aligning, like this. Unless I'm using an editor that can't do that automatically, in which case I just use spaces.

A A 2 3 5 8 K
Nov 24, 2003
Illiteracy... what does that word even mean?

mr_jim posted:

I use tabs for indenting, and spaces for aligning, like this.

There's nothing else that makes any sense. It's like people who insist on only spaces or only tabs can't put aside the emotional need to take a side in a religious war and can't get on board with having the benefits of each.

Jerry Bindle
May 16, 2003

A A 2 3 5 8 K posted:

There's nothing else that makes any sense. It's like people who insist on only spaces or only tabs can't put aside the emotional need to take a side in a religious war and can't get on board with having the benefits of each.

Same here. Not sure about 'modern' editors like notepad++ or what sane IDE's use, but in VIM you can set it up to present the user with tabs/spaces editing while internally everything is spaces; so you end up with the best of all possibly worlds.

wellwhoopdedooo
Nov 23, 2007

Pound Trooper!

dietary supplement posted:

Same here. Not sure about 'modern' editors like notepad++ or what sane IDE's use, but in VIM you can set it up to present the user with tabs/spaces editing while internally everything is spaces; so you end up with the best of all possibly worlds.

What? From what I've seen, it's the worst of both possible worlds. Maybe I just have it configured wrong, but it always does this poo poo:

code:
int main (int    argc,
..........char** argv, // I press enter here, and
--->--->..char** envp) // Next line is horseshit
Do you have a config that doesn't do that but still inserts a tab when you hit tab?

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer
The Super Delegate:



:derp:

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

beuges posted:

At a previous job, I inherited a project with a couple of .cpp files being well over 15000 lines each... one class per file.

27000 lines is the largest I've seen for a single .cpp file so for... and that's one class.

Jerry Bindle
May 16, 2003

wellwhoopdedooo posted:

What? From what I've seen, it's the worst of both possible worlds. Maybe I just have it configured wrong, but it always does this poo poo:

code:
int main (int    argc,
..........char** argv, // I press enter here, and
--->--->..char** envp) // Next line is horseshit
Do you have a config that doesn't do that but still inserts a tab when you hit tab?

I have it set up so that when you hit tab, or when it autoindents, it inserts 4 spaces and mapped shift-tab to delete the the value of the tabstop (4). <x> or backspace deletes one space. works for me!

Lysandus
Jun 21, 2010
code:
<?php
//namespace SECRETNAMESPACE;

class DO_SecretTable {

	/** 
	* @var string
	*/ 	
	var $Column0;
	/** 
	* @var string
	*/ 	
	var $Column1;
	/** 
	* @var string
	*/ 	
	var $Column2;
	/** 
	* @var string
	*/ 	
	var $Column3;
	/** 
	* @var string
	*/ 	
	var $Column4;
	/** 
	* @var string
	*/ 	
	var $Column5;
	/** 
	* @var string
	*/ 	
	var $Column6;
	/** 
	* @var string
	*/ 	
	var $Column7;
	/** 
	* @var string
	*/ 	
	var $Column8;
	/** 
	* @var string
	*/ 	
	var $Column9;
	/** 
	* @var string
	*/ 	
	var $Column10;
}

?>
It goes to 46

Room Temperature
Oct 16, 2007

mildly amusing

dietary supplement posted:

I have it set up so that when you hit tab, or when it autoindents, it inserts 4 spaces and mapped shift-tab to delete the the value of the tabstop (4). <x> or backspace deletes one space. works for me!

But that's not using tabs for indentation at all. Now anyone who reads your code has to use 4 spaces = 1 tab, no matter what their personal viewing preferences are. The idea is use actual tab characters for indentation levels. Then, if you need to move the text on a line farther than that use spaces. That way the way the indentation looks can be customized per IDE/editor without messing up the space-aligned text. The problem VIM has is that when it auto-indents it uses tabs where it should use spaces, or it uses spaces where it should use tabs, depending on your configuration.

Your way:
code:
....if (expr) {
........doSomething(arg1,
....................arg2,
....................arg3);
....}
Better way:
code:
--->if (expr) {
--->--->doSomething(arg1,
--->--->............arg2,
--->--->............arg3);
--->}
Vim's auto-indenting:
code:
--->if (expr) {
--->--->doSomething(arg1,
--->--->............arg2,  // did this one manually
--->--->--->--->--->arg3); // auto-indented: looks wrong in other editors
--->}

Thel
Apr 28, 2010

hieronymus posted:

27000 lines is the largest I've seen for a single .cpp file so for... and that's one class.

I once wrote a 20k LOC GUI application ... in a single file. :derp:

(Hey I didn't know any better. And it worked. So nyah.)

mr_jim
Oct 30, 2006

OUT OF THE DARK

Room Temperature posted:

But that's not using tabs for indentation at all. Now anyone who reads your code has to use 4 spaces = 1 tab, no matter what their personal viewing preferences are. The idea is use actual tab characters for indentation levels. Then, if you need to move the text on a line farther than that use spaces. That way the way the indentation looks can be customized per IDE/editor without messing up the space-aligned text. The problem VIM has is that when it auto-indents it uses tabs where it should use spaces, or it uses spaces where it should use tabs, depending on your configuration.

Your way:
code:
....if (expr) {
........doSomething(arg1,
....................arg2,
....................arg3);
....}
Better way:
code:
--->if (expr) {
--->--->doSomething(arg1,
--->--->............arg2,
--->--->............arg3);
--->}
Vim's auto-indenting:
code:
--->if (expr) {
--->--->doSomething(arg1,
--->--->............arg2,  // did this one manually
--->--->--->--->--->arg3); // auto-indented: looks wrong in other editors
--->}

I've only gotten it to work in emacs. I gave up trying to make vim do it.

ToxicFrog
Apr 26, 2008


Room Temperature posted:

Your way:

Better way:

Vim's auto-indenting:

This poo poo right here is why I use spaces everywhere, despite agreeing in principle with "indent with tabs, align with spaces"; I have never used an editor that doesn't gently caress up in this manner as soon as you start actually aligning things.

mr_jim
Oct 30, 2006

OUT OF THE DARK

ToxicFrog posted:

This poo poo right here is why I use spaces everywhere, despite agreeing in principle with "indent with tabs, align with spaces"; I have never used an editor that doesn't gently caress up in this manner as soon as you start actually aligning things.

Emacs with that package that I linked to earlier does it right. Hit tab, it correctly indents and aligns the current line, and you're all set.

npe
Oct 15, 2004
tabchat should be in YOSPOS, post more code horrors

Today, I stumbled across this line. It made me curious, and I now regret my curiosity.

code:
public final static String NETWORK_ERROR_MSG_SYS = "java.net.SocketException: Network is unreachable: connect";
What could this possibly be used for? Well, it's referenced in a utility class...

code:
	        public static boolean isNetworkConnectionError(Exception exception) {
	               
	                if(exception.getMessage().contains(Globals.NETWORK_ERROR_MSG_SYS)) {
	                        return true;
	                } else {
	                        return false;
	                }
	        }
That's kind of weird. Where could this possibly be useful? There's a few of these floating around:

code:
	        public void checkNetworkConnectionException(Exception e) {
	
	                if(Util.isNetworkConnectionError(e)) {
	                        hasNetworkConnection = false;
	                }
	        }
I'm still confused. On the other hand, that explains all the code littered all over the place like this:

code:

catch (Exception e)
{
  checkNetworkConnectionException(e);
}

But what on earth is it DOING? How is that boolean being used? What is going on here?

code:
	        public void checkIsNetworkConnected() throws Exception{
	       
	                if(!hasNetworkConnection) {
	                        throw new Exception(Globals.NETWORK_ERROR_MSG_1);
	                }
	        }
Oh, of course...

code:
public final static String NETWORK_ERROR_MSG_1 = "Network Connection Has Been Lost";
:suicide:

NotShadowStar
Sep 20, 2000
Holy poo poo they circumvented the Exception message system by making their own that does... exactly the same thing.

Someone should show this person Object.getClass() or instanceof() and watch people start shooting themselves.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Thel posted:

I once wrote a 20k LOC GUI application ... in a single file. :derp:

(Hey I didn't know any better. And it worked. So nyah.)

I've got a shared VB web service file; 67,000 lines.

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

Thel posted:

I once wrote a 20k LOC GUI application ... in a single file. :derp:

(Hey I didn't know any better. And it worked. So nyah.)

The very first 'big' program I ever wrote was an app that did a 2D engineering simulation. All of the input file parsing, data structure setup, simulation, and output reporting were jammed into one single method that spanned tens of pages.

That method was the "Run Simulation" menu item's OnClick event handler.

Jerry Bindle
May 16, 2003
Had to do some ASM work on a very small MCU today. It has a 33 count instruction set so theres a lot of tricks you have to do to get stuff done, like using a xor and the zero flag to test two values for equality. Better yet, there is only one way to do flow control: if a bit is set/clear skip the next instruction. So you end up with code that looks like this:

code:
cpnibseq	macro	file	; Compare Nibbles, Skip if Equal
	swapf	file, w
	xorwf	file, w
	btfss	STATUS, Z
	endm
The horror is coming from inside the instruction set. C compilers exist for this part now, but this stuff is still being written in ASM. wah wah.

PrBacterio
Jul 19, 2000

dietary supplement posted:

Had to do some ASM work on a very small MCU today. It has a 33 count instruction set so theres a lot of tricks you have to do to get stuff done, like using a xor and the zero flag to test two values for equality. Better yet, there is only one way to do flow control: if a bit is set/clear skip the next instruction. So you end up with code that looks like this:

code:
cpnibseq	macro	file	; Compare Nibbles, Skip if Equal
	swapf	file, w
	xorwf	file, w
	btfss	STATUS, Z
	endm
The horror is coming from inside the instruction set. C compilers exist for this part now, but this stuff is still being written in ASM. wah wah.
What on earth is it with embedded development using all of these weird, horrific alien nightmares of CPU architectures? Why don't you guys just use some cheap ARM clone or an AVR32 or somesuch, or hell, even just a Z80-clone (I think they still make those?) would be better than some of this poo poo, if a 32-bit risc cpu really is too complex for whatever project you're up to :stare:

Jerry Bindle
May 16, 2003

PrBacterio posted:

What on earth is it with embedded development using all of these weird, horrific alien nightmares of CPU architectures? Why don't you guys just use some cheap ARM clone or an AVR32 or somesuch, or hell, even just a Z80-clone (I think they still make those?) would be better than some of this poo poo, if a 32-bit risc cpu really is too complex for whatever project you're up to :stare:

Its all about cost. A cheap ARM is probably $5-$10, this chip I think is around $0.12 $0.30 with volume pricing. This chip in particular is a PIC10, 6 pins, super cheap/small. I hear they're in a lot of throw-away products like pregnancy tests, as well as in more expensive products doing things like power sequencing beefier processors/peripherals.

Jerry Bindle fucked around with this message at 01:17 on Aug 6, 2011

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug

NotShadowStar posted:

Holy poo poo they circumvented the Exception message system by making their own that does... exactly the same thing.

Someone should show this person Object.getClass() or instanceof() and watch people start shooting themselves.

instanceof is an operator, not a method.

Bozart
Oct 28, 2006

Give me the finger.
I'm excited that so many people have so much new to say about the groundbreaking topic of tabs vs spaces! I never knew that tabs could actually be DIFFERENT depending on different environments!

To actually loving contribute I don't have code but a story. As part of some redundancy building so that some guy could go on vacation for a day or two, I was shown the way that millions of dollars of trades are manually checked by some of my financial buddies, and it turns out that it is a bunch of copy and pasted recorded excel macros that rely on magic numbers, strings, and need to be "tweaked" weekly or it won't work correctly. And the kicker is that they use this process because the people are are supposed to be doing it (who number in the low 100's) are so bad at their job that a recorded macro works more reliably and faster than them.

So excuse me while I don't shed many tears for something that doesn't result in mistakes worth more than your lifetime income. Caring about useless poo poo is the horror, go fix something important.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Here's everyone's warm fuzzy feeling for the day: We're not insane, other people see these horrible things and agree with us.

It helps to remember that, especially when dealing with things that seem stupid but are seen as acceptable by co-workers. Like having merging turned off in TFS, and when an hour-and-a-half lunch locked me out of a file I needed to work on, being told "you should've told me before I went to lunch, LOL" :what:

The explanation is "we're a small group, so we can talk to each other!" My response was "I can't talk to you when you're missing for an hour and a half"

Response: "..."

My favorite moment so far was when I was giving a short talk on unit testing methodologies. One guy said "well, i don't care if it works properly as long as it gives a descriptive error message when it fails," and my response was "If you test properly, you should rarely have failure cases"

That shut him up. He hates me now. I hope he gets fired due to a huge, breaking bug he introduces that is reported in a very clear, concise manner so that his replacement can fix it.

Changing jobs recently wasn't a mistake (more money, better commute, saner management), but I'm used to being in an environment where my co-workers are badasses who raise the bar constantly. Now I'm the "badass," and I'm not learning dick at work (luckily, I take my career seriously and study on my own time), and the other guys are 10+ years older than me and don't want to learn new poo poo. It's an uphill battle, but at least the CTO is on my side.

New Yorp New Yorp fucked around with this message at 07:53 on Aug 6, 2011

Axel Rhodes Scholar
May 12, 2001

Courage Reactor

Ithaqua posted:

It helps to remember that, especially when dealing with things that seem stupid but are seen as acceptable by co-workers. Like having merging turned off in TFS, and when an hour-and-a-half lunch locked me out of a file I needed to work on, being told "you should've told me before I went to lunch, LOL" :what:

The explanation is "we're a small group, so we can talk to each other!" My response was "I can't talk to you when you're missing for an hour and a half"

Response: "..."

Oh god, gently caress file locking in source control. I'm just working out my notice at a company that uses VSS (well, half of it does; there are literally skunkworks SVN and git servers that not everyone knows about, which I think says quite a lot) and the guy in charge of the VSS server doesn't know how to force-unlock a file (I don't know if that's even possible, but it absolutely should be).

So we have ridiculous situations like people forgetting to 'undo checkout' a solution file before going on a three week holiday, and the only way around it is to duplicate that entire source tree in the VCS and work off the new one. This is compounded by how insanely frequently the VSS plugin for visual studio decides to check stuff out for you (e.g. initiate (not complete! just initiate!) a drag'n'drop operation on a project's file list - bang, checked out).

There's even one file in our source control permanently checked out to a guy who left the country a few months ago, and I'm pretty sure it will _never_ get unlocked.

Axel Rhodes Scholar
May 12, 2001

Courage Reactor

Actually while I'm bitching about my soon-to-be-ex-job, the coding horror that's been pissing me off for several months (and absolutely contributed to me starting to look for and getting a new job) is ridiculous cargo-cult design.

Basically - I wrote an IPv6 fuzzer a while ago. I used YAML to specify the fuzzing rule files, because I'm a ruby dork and I'm lazy. I found a Windows bug and got it reported in a patch tuesday (this is a big deal in a security company). Management decides that the success here was clearly because I used YAML, therefore YAML is now a feature and is literally appearing in the marketing copy for our (completely unrelated) fuzzer product.

They assigned another guy to write a YAML-based fuzzer add-on for our actual fuzzer product (the thing I made was just an internal tool for sort of testing the waters in terms of IPv6 vulns); guy wound up writing a horrible C++ mashup of libyaml, bison and flex, mostly using libyaml as a lexer (and nothing else) and parsing a very much non-YAML language he's concocted himself that has idiotic types and sigils on variables and braces for scoping and ick.

The reason why it's been pissing me off, aside from the whole 'this is not yaml but you keep calling these yaml files' thing, is that I got tasked with solving the memory leaks that occur in this genius design, because the entire execution is actually carried out inside the bison grammar. Meaning it is insanely difficult to figure out the program flow, and where allocations happen and where pointer ownership is passed (to the RAII crew: god I wish and I don't even like RAII). They're probably going to have to go to some sort of autopointer or whatever, but there's no time to get company approval to include another library in the project (yes that sentence means what you think it means. even BSD-style licensed libraries.).

I've got three days left at the company and I've taken this software from leaking 350MB per run to leaking 8MB per run and they can just live with it.

Adbot
ADBOT LOVES YOU

Zamujasa
Oct 27, 2010



Bread Liar

dazjw posted:

... and the guy in charge of the VSS server doesn't know how to force-unlock a file (I don't know if that's even possible, but it absolutely should be).

I hope it's not as easy as it seems but about thirty seconds of Googling revealed this solution.

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