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
Zakalwe
May 12, 2002

Wanted For:
  • Terrorism
  • Kidnapping
  • Poor Taste
  • Unlawful Carnal Gopher Knowledge

fletcher posted:

I can't imagine why they even put something like that in. Are people really that lazy that they can't keep their code formatted properly as they write it?

I spend most of my "coding time" thinking through algorithms or optimizing code. Typing is the tedious part. I've set up my indenter to format my code in the style I like. I use autocomplete. It's a tool. Do you use an IDE?

Adbot
ADBOT LOVES YOU

haveblue
Aug 15, 2005



Toilet Rascal
Autoindenting is one thing, but moving code around vertically would throw me off all the time.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Zakalwe posted:

I spend most of my "coding time" thinking through algorithms or optimizing code. Typing is the tedious part. I've set up my indenter to format my code in the style I like. I use autocomplete. It's a tool. Do you use an IDE?

Yeah, I use autocomplete all the time, I couldn't live without it. I have my indenter setup the way I like as well, and it will add curly braces for me at convenient times. None of that has to do with what I was talking about. I use eclipse.

Zakalwe
May 12, 2002

Wanted For:
  • Terrorism
  • Kidnapping
  • Poor Taste
  • Unlawful Carnal Gopher Knowledge

fletcher posted:

Yeah, I use autocomplete all the time, I couldn't live without it. I have my indenter setup the way I like as well, and it will add curly braces for me at convenient times. None of that has to do with what I was talking about. I use eclipse.

Sorry dude, read you completely wrong. Thought you were pulling out that "real programmers do X" bullshit.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Perhaps you should all try the Forth way of organizing code

Thinking Forth posted:

Some Forth practitioners advocate storing source code in variable-length, named text files, deliberately emulating the approach used by traditional compilers and editors. This approach may become more and more common, but its usefulness is still controversial.

Sure, it's nice not to have to worry about running out of room in a screen, but the hassle of writing in a restricted area is compensated for by retaining control of discrete chunks of code. In developing an application, you spend a lot more time loading and reloading screens than you do rearranging their contents.

Infinite-length files allow sloppy, disorganized thinking and bad factoring. Definitions become longer without the discipline imposed by the 1K block boundaries. The tendency becomes to write a 20K file, or worse: a 20K definition.

"what is stackholm syndrome?" - leo brodie, 1984, 1994, 2004

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Otto Skorzeny posted:

By the way, does Java make any guarantees as to the layout of the class based on the order of declaration of members?

In case you weren't being ironic: no. IIRC there was a paper about implementing profile-directed field layout in the Jikes RVM.

Goat Bastard
Oct 20, 2004

fletcher posted:

Eclipse lists it in alphabetical order in the sidebar while leaving the code alone as well, but if you do Source->Format or Source->Cleanup or whatever the hell it is it will rearrange everything.

I can't imagine why they even put something like that in. Are people really that lazy that they can't keep their code formatted properly as they write it?

The real horror is that it can be set up to do that every time you save.

But eclipse still rocks.

Outlaw Programmer
Jan 1, 2008
Will Code For Food

Otto Skorzeny posted:

By the way, does Java make any guarantees as to the layout of the class based on the order of declaration of members?

For the most part, you can put anything in any order you want. Initializer blocks are run from top-to-bottom, but if you have more than one, and they depend on each other, then there's something wrong with your design anyway.

CoasterMaster
Aug 13, 2003

The Emperor of the Rides


Nap Ghost

Goat Bastard posted:

The real horror is that it can be set up to do that every time you save.

But eclipse still rocks.

The worst one is where it's set to remove unused local variables upon save. I, out of instinct, hit CTRL + S every time I finish typing anything. Frequently I'll go like this:

code:
int someVar = 2;
then hit CTRL + S and then that line will disappear. Thankfully I turned it off :)

Also, one of our projects at work is in a weird half-Mavenized state which Eclipse doesn't like and really messes up the 'build automatically option' which really sucks.

plushpuffin
Jan 10, 2003

Fratercula arctica

Nap Ghost
I found this today while working on a C++ program. Most of the class's variables have get-()/set-() functions, but... this one variable... I'm not sure what's going on here, but I don't like it.

code:
long& GetCaseId() { return mCaseId; };
long GetCaseId() const { return mCaseId; };

UraniumAnchor
May 21, 2006

Not a walrus.

plushpuffin posted:

I found this today while working on a C++ program. Most of the class's variables have get-()/set-() functions, but... this one variable... I'm not sure what's going on here, but I don't like it.

code:
long& GetCaseId() { return mCaseId; };
long GetCaseId() const { return mCaseId; };

Presumably it's so:

code:
obj.GetCaseId() = x;
works, but it's... not exactly a common way of writing a setter.

plushpuffin
Jan 10, 2003

Fratercula arctica

Nap Ghost

UraniumAnchor posted:

Presumably it's so:

code:
obj.GetCaseId() = x;
works, but it's... not exactly a common way of writing a setter.

Yes, I understand what it does and how, I just don't know why anyone would bother writing it that way, especially when there are fifty other normal get/set functions in the same class.

1337JiveTurkey
Feb 17, 2005

Otto Skorzeny posted:

By the way, does Java make any guarantees as to the layout of the class based on the order of declaration of members?

There's no guarantees or need to do so. The class file format begins with some identifiers and then a constants pool. Everything else within the file refers to the constants pool including the class name itself. When the class is loaded the constants pool is interned, creating exactly one canonical copy of each constant in the permgen space which everything refers to. Since method, class and field references are also in the constants pool, interning dynamically links the program.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

UraniumAnchor posted:

Presumably it's so:

code:
obj.GetCaseId() = x;
works, but it's... not exactly a common way of writing a setter.

What. That's practically a standard idiom. (Granted, it's an idiom that dumb people use, but that's neither here nor there.)

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"

Avenging Dentist posted:

What. That's practically a standard idiom. (Granted, it's an idiom that dumb people use, but that's neither here nor there.)
I've seen a lot of dumb idioms, but never this one.

Zhentar
Sep 28, 2003

Brilliant Master Genius

sex offendin Link posted:

Autoindenting is one thing, but moving code around vertically would throw me off all the time.

I don't know where most of my code is vertically. It's convenient having two related functions next to each other, but otherwise I'm just Ctrl+F/jumping to what I'm looking for.

What really sucks is when....

Otto Skorzeny posted:

Perhaps you should all try the Forth way of organizing code


"what is stackholm syndrome?" - leo brodie, 1984, 1994, 2004

You're working in MUMPS and you have a 32k routine size limit and you have to spread your code across 17 different routines.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Zhentar posted:

What really sucks is when....


You're working in MUMPS and you have a 32k routine size limit and you have to spread your code across 17 different routines.

This sentence went on 19 words too long.

Seriously, if you work at Epic Systems, just loving quit, it's not worth it.

Bozart
Oct 28, 2006

Give me the finger.
Well, Hearts of Iron 3 came out today, with plenty of broken code in it. I caught myself trying to debug the ai files in a game I want to play for fun. I deal with that enough at work. The problems are probably much deeper than I can see or fix. Here's an example of the quality that sent me over the edge:

code:
factor = math.min(factor, factor_left)
factor_left = math.max(factor_left - factor, 0.0)
Jesus Christ Johan, do you not know that a small number subtracted from a bigger number is always non negative?

raminasi
Jan 25, 2005

a last drink with no ice

Avenging Dentist posted:

What. That's practically a standard idiom. (Granted, it's an idiom that dumb people use, but that's neither here nor there.)

serious question: does the idiom include putting "Get" in the method name

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

GrumpyDoctor posted:

serious question: does the idiom include putting "Get" in the method name

How can the class give the variable to the caller to modify it if it doesn't get it first?

Zhentar
Sep 28, 2003

Brilliant Master Genius

Avenging Dentist posted:

just loving quit, it's not worth it.

I like it. (My job, not MUMPS)

Otto Skorzeny posted:

"what is stackholm syndrome?" - Zhentar, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh


Zhentar posted:

I like it. (My job, not MUMPS)

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
code:
for ($i=0; $i < sizeof($order->products); $i++) {
                $my_path = tep_get_product_path(tep_get_prid($order->products[$i]['id']));
                $sub_cat_ids = split("[_]", $my_path);
                for ($iii = 0; $iii < count($sub_cat_ids); $iii++) {
                  for ($ii = 0; $ii < count($cat_ids); $ii++) {
                    if ($sub_cat_ids[$iii] == $cat_ids[$ii]) {
                      if ($get_result['coupon_type'] == 'P') {
                        $p_processed = true;         
                        $pr_c = $this->product_price(tep_get_prid($order->products[$i]['id']));
                        $pod_amount = round($pr_c*10)/10*$c_deduct/100;
                        $od_amount = $od_amount + $pod_amount;
                        continue 3; 
                      } else {
                        $od_amount = $c_deduct;
                        continue 3;
                      }
                    }
                  }
                }
This 18 lines or whatever should be all the evidence anyone should ever need to never use oscommerce.

musclecoder
Oct 23, 2006

I'm all about meeting girls. I'm all about meeting guys.

TRex EaterofCars posted:

code:
for ($i=0; $i < sizeof($order->products); $i++) {
                $my_path = tep_get_product_path(tep_get_prid($order->products[$i]['id']));
                $sub_cat_ids = split("[_]", $my_path);
                for ($iii = 0; $iii < count($sub_cat_ids); $iii++) {
                  for ($ii = 0; $ii < count($cat_ids); $ii++) {
                    if ($sub_cat_ids[$iii] == $cat_ids[$ii]) {
                      if ($get_result['coupon_type'] == 'P') {
                        $p_processed = true;         
                        $pr_c = $this->product_price(tep_get_prid($order->products[$i]['id']));
                        $pod_amount = round($pr_c*10)/10*$c_deduct/100;
                        $od_amount = $od_amount + $pod_amount;
                        continue 3; 
                      } else {
                        $od_amount = $c_deduct;
                        continue 3;
                      }
                    }
                  }
                }
This 18 lines or whatever should be all the evidence anyone should ever need to never use oscommerce.

I see you're working on the genocide that is the ot_coupon module. May god have mercy on your soul.

spiritual bypass
Feb 19, 2008

Grimey Drawer

TRex EaterofCars posted:

code:
for ($i=0; $i < sizeof($order->products); $i++) {
                $my_path = tep_get_product_path(tep_get_prid($order->products[$i]['id']));
                $sub_cat_ids = split("[_]", $my_path);
                for ($iii = 0; $iii < count($sub_cat_ids); $iii++) {
                  for ($ii = 0; $ii < count($cat_ids); $ii++) {
                    if ($sub_cat_ids[$iii] == $cat_ids[$ii]) {
                      if ($get_result['coupon_type'] == 'P') {
                        $p_processed = true;         
                        $pr_c = $this->product_price(tep_get_prid($order->products[$i]['id']));
                        $pod_amount = round($pr_c*10)/10*$c_deduct/100;
                        $od_amount = $od_amount + $pod_amount;
                        continue 3; 
                      } else {
                        $od_amount = $c_deduct;
                        continue 3;
                      }
                    }
                  }
                }
This 18 lines or whatever should be all the evidence anyone should ever need to never use oscommerce.
What a horror!

I always use i,j,k for my n^3 for loops :colbert:

Blue Footed Booby
Oct 4, 2006

got those happy feet

royallthefourth posted:

What a horror!

I always use i,j,k for my n^3 for loops :colbert:

I'm having trouble coming up with anything worse than i, iii, and ii in that order other than x, l, and platypus or something like that. At least i,j,k are easy to keep track of.

Edit: lI, Il, l1 could be amusing, depending on the font.

baquerd
Jul 2, 2007

by FactsAreUseless
My guess is it started out i, ii, iii, and at some point the programmer decided to just switch the loop order without changing anything else.

Sebbe
Feb 29, 2004

quadreb posted:

My guess is it started out i, ii, iii, and at some point the programmer decided to just switch the loop order without changing anything else.

I think I'll start using roman numerals as names for nested loop variables in the future.

PraxxisParadoX
Jan 24, 2004
bittah.com
Pillbug

TRex EaterofCars posted:

code:
for ($i=0; $i < sizeof($order->products); $i++) {
                $my_path = tep_get_product_path(tep_get_prid($order->products[$i]['id']));
                $sub_cat_ids = split("[_]", $my_path);
                for ($iii = 0; $iii < count($sub_cat_ids); $iii++) {
                  for ($ii = 0; $ii < count($cat_ids); $ii++) {
                    if ($sub_cat_ids[$iii] == $cat_ids[$ii]) {
                      if ($get_result['coupon_type'] == 'P') {
                        $p_processed = true;         
                        $pr_c = $this->product_price(tep_get_prid($order->products[$i]['id']));
                        $pod_amount = round($pr_c*10)/10*$c_deduct/100;
                        $od_amount = $od_amount + $pod_amount;
                        continue 3; 
                      } else {
                        $od_amount = $c_deduct;
                        continue 3;
                      }
                    }
                  }
                }
This 18 lines or whatever should be all the evidence anyone should ever need to never use oscommerce.

For the past 6 years I've worked with a codebase that "grew" out of oscommerce. The amount of sheer... god, I can't think of a word bad enough to describe it, sickens me. Thankfully I'm moving to a new job at the end of the month ><

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

PraxxisParadoX posted:

For the past 6 years I've worked with a codebase that "grew" out of oscommerce. The amount of sheer... god, I can't think of a word bad enough to describe it, sickens me. Thankfully I'm moving to a new job at the end of the month ><

I just finished writing a wrapper in CodeIgniter around OSC. It's amazing the amount of bullshit global crap you need to provide to run some of this poo poo.

It's kind of funny that the part I hate most about php (specifically it's half-assed accidental flexibility) is the exact mechanism I used to make this work.

ctz
Feb 6, 2003

PraxxisParadoX posted:

For the past 6 years I've worked with a codebase that "grew" out of oscommerce. The amount of sheer... god, I can't think of a word bad enough to describe it, sickens me.
'PHP'?

Incoherence
May 22, 2004

POYO AND TEAR

Sebbe posted:

I think I'll start using roman numerals as names for nested loop variables in the future.
Another way to make people crazy: if you ever have an opportunity to write a 4-level nested loop, use the variables i, ii, iii, and iiii.

The real WTF is, of course, the fact that you're writing a 4-level nested loop, but that's another story.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Sebbe posted:

I think I'll start using roman numerals

code:
#define I 1
...
#define LVI 56
...
#define DCCXXXV 735
...

No Safe Word
Feb 26, 2005

Incoherence posted:

Another way to make people crazy: if you ever have an opportunity to write a 4-level nested loop, use the variables i, ii, iii, and iiii.

The real WTF is, of course, the fact that you're writing a 4-level nested loop, but that's another story.

Or a four-level nested SQL join with table aliases T, TT, TTT, and TTTT. Sadly such a beast exists, and they exist in numbers :smith:

Sebbe
Feb 29, 2004

pokeyman posted:

code:
#define I 1
...
#define LVI 56
...
#define DCCXXXV 735
...

code:
for (int i = I-I; i <= III; i++) {
	for (int ii = II-II; ii <= i; ii++) {
		for (int iii = III-III; iii < ii; iii++) {
			IIII[i][II][iii] = I+ii+III;
		}
	}
}

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

No Safe Word posted:

Or a four-level nested SQL join with table aliases T, TT, TTT, and TTTT. Sadly such a beast exists, and they exist in numbers :smith:

hahahaha, at another job:

code:
SELECT     t1.ItItemNo, t1.ItCountryFlag, t1.ItVndItemName, t1.ItDescSys1, t1.ItVendNo, t1.CatEnt, t1.ICL_ID, t1.ICLFreeShipping, t1.ICLParent, t1.ICLPhantom, 
                      t1.ICLEditor, t1.ICLModDate, t1.ICLActive, t1.ICLSource, t1.ICLStatus, t1.ICLForeignCopyID, t1.CP_ID, t1.CpReady, t1.CpBrandNo, t1.CpName, 
                      t1.CpDescBenefit, t1.CpDescShort, t1.CpDescLong, t1.CpItem_PhantomWords, t1.CpSpecs, t1.CpNotes, t1.CpEditorInitials, t1.CpModDate, 
                      t1.CpModFlag, t1.CpSynch, t1.CpOrphan, t1.CpDescCheckSum, t1.CpBug, t1.CpImage1, t1.CpImage2, t1.CpImage1Caption, t1.CpImage2Caption, 
                      t1.CpRouting, t1.CpStatus, t1.CpDescLongUse, t1.CpPName, t1.CpPDescShort, t1.CpPDescLong, t1.CpPDescBenefit, t1.CpPNotes, t1.CpPImage, 
                      t1.BrName, t1.BrBrandNo, t1.ICt_Cat1, t1.ICt_Cat2, t1.ICt_Cat3, t1.Cat0, t1.Cat0Desc, t1.Cat1Desc, t1.ItStat, t1.RebateCount, t1.IF_KitFlag, 
                      t1.IF_KitCompFlag, t1.IF_HazFlag, t1.IF_OvrSzFlag, t1.IF_AttributeCount, t1.IF_SeeAlsoCount, t1.IF_RelatedCount, t1.CpLang, t1.ICLAssignee, 
                      t1.ICLCreator, t1.ICLSourcePending, t5.CH_CurrSymb, t5.CH_CurrFormat, t4.Cat2, t4.Cat2Desc, t2.PS_ID, t2.PsItemNo, t2.PsCountryFlag, t2.PsPrice, 
                      t2.PsPriceMAP, t2.PsQtyForPrice, t2.PsPriceText, t2.PsItemAvail, t2.PsItemStat, t2.PsPriceCode, t2.PsQtyAvail, t2.PsPriceLevel, t2.PsPriceDiff, 
                      t2.PsQtyAvailAll, t2.PsQtyDaysWorth, t2.PsAvgLeadTime, t2.PsExpDate, t2.PsExpQtyAvail, t2.PsRefreshDate, t2.PsStockFlag, t2.PsPriceType
FROM         viewItemCopy AS t1 INNER JOIN
                      tblPricesSummary AS t2 ON t1.ItItemNo = t2.PsItemNo AND t1.ItCountryFlag = t2.PsCountryFlag LEFT OUTER JOIN
                      tblCat2 AS t4 ON t1.ICt_Cat2 = t4.Cat2 AND t1.ItCountryFlag = t4.Cat2Country LEFT OUTER JOIN
                      tblCountryHost AS t5 ON t1.ItCountryFlag = t5.CH_CountryFlag
loving assholes. viewItemCopy is an abortion unto itself as well.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

Incoherence posted:

Another way to make people crazy: if you ever have an opportunity to write a 4-level nested loop, use the variables i, ii, iii, and iiii.

The real WTF is, of course, the fact that you're writing a 4-level nested loop, but that's another story.
If you're dealing with 4-column matrices, it can be pretty common. I normally use t,u,v,w in those cases because when iterating the indexes really typically refer to vectors. So you'd get expressions like A[u] + B[v] - project(B[v],M)

I kinda miss the simple elegance of mathematical programming :unsmith: loving enterprise Java :smithicide:

Lexical Unit
Sep 16, 2003

pokeyman posted:

code:
#define I 1
...
#define LVI 56
...
#define DCCXXXV 735
...
Everyone knows macros are horrible, so use mpl::string instead!
code:
template<char> struct numeral_c { static const long value = 0; };
template<> struct numeral_c<'M'> { static const long value = 1000; };
template<> struct numeral_c<'D'> { static const long value = 500; };
template<> struct numeral_c<'C'> { static const long value = 100; };
template<> struct numeral_c<'L'> { static const long value = 50; };
template<> struct numeral_c<'X'> { static const long value = 10; };
template<> struct numeral_c<'V'> { static const long value = 5; };
template<> struct numeral_c<'I'> { static const long value = 1; };
template<> struct numeral_c<'i'> { static const long value = 1000; };
template<> struct numeral_c<'v'> { static const long value = 5000; };
template<> struct numeral_c<'x'> { static const long value = 10000; };
template<> struct numeral_c<'l'> { static const long value = 50000; };
template<> struct numeral_c<'c'> { static const long value = 100000; };
template<> struct numeral_c<'d'> { static const long value = 500000; };
template<> struct numeral_c<'m'> { static const long value = 1000000; };

template<class Total, class Iter>
struct numeral_fop
{
	typedef typename boost::mpl::deref<Iter>::type element;
	typedef typename boost::mpl::deref<typename boost::mpl::next<Iter>::type>::type next_element;
	typedef typename boost::mpl::if_<
		boost::mpl::less<
			typename boost::mpl::long_<numeral_c<element::value>::value>::type
			, typename boost::mpl::long_<numeral_c<next_element::value>::value>::type
		>
		, boost::mpl::long_<Total::value - numeral_c<element::value>::value>
		, boost::mpl::long_<Total::value + numeral_c<element::value>::value>
	>::type type;
};

template<class String> struct numeral :
boost::mpl::iter_fold<
	String
	, boost::mpl::long_<0>
	, numeral_fop<boost::mpl::deref<boost::mpl::_1>, boost::mpl::_2>
>::type
{ };

typedef numeral<boost::mpl::string<'I'>::type>::type I;
typedef numeral<boost::mpl::string<'LVI'>::type>::type LVI;
typedef numeral<boost::mpl::string<'DCCX','XXV'>::type>::type DCCXXXV;
Considering this code is my first foray into boost::mpl, I figure this thread is a good place for it.

Zakalwe
May 12, 2002

Wanted For:
  • Terrorism
  • Kidnapping
  • Poor Taste
  • Unlawful Carnal Gopher Knowledge

Lexical Unit posted:

an unholy abomination.

Jesus H Christ. I think I need to lie down for a minute.

Adbot
ADBOT LOVES YOU

Lexical Unit
Sep 16, 2003

Tell me about it! That stupid code accepts things like IIII and IIV. Madness.

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