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
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.

Adbot
ADBOT LOVES YOU

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.

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.

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

awesmoe posted:

Because 1.5 was only released near the end of 2004 and before that there was no replace all method, iirc

replaceAll was in 1.4. At least according to the javadoc.

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

Parantumaton posted:

Java's String#replaceAll(String, String) is regex based which means there's the overhead of generating internal Pattern object for the actual regex, creating a Matcher object from the said Pattern object and then calling Matcher#replaceAll(String) to get the output. If all you need is simple replacement ("change all 'a':s to 'b':s") which is going to get used a lot in your application then rolling out your own #replaceAll() will actually result in a lot faster throughput than the Java's native regex one. Same applies especially to Pattern#split(String) too.

In reality, all the text above means that I've actually done the same thing myself and I need to justify my micro-optimizations to not fall into despair.

Apache Commons to the rescue.

http://commons.apache.org/lang/api-...va.lang.String)

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
:( no wonder I can't find any uses of method getTaxRateUS().

code:
private static double getTaxRate(String strTaxMode, 
    ServletContext application, 
    HttpServletRequest request, 
    String strPostalCode) {
	if (strPostalCode == null || strPostalCode.length() == 0) {
		return 0;	
	}
	try {
		Object[] args = new Object[3];
		args[0] = (Object) application;
		args[1] = (Object) request;
		args[2] = (Object) strPostalCode;
		Class[] methodParameters = new Class[3];
		methodParameters[0] = Class.forName("javax.servlet.ServletContext");
		methodParameters[1] = Class.forName("javax.servlet.http.HttpServletRequest");;
		methodParameters[2] = Class.forName("java.lang.String");
		Method[] arrMethods = Tax.class.getDeclaredMethods();
		Method methodToExecute = null;
		if (arrMethods.length > 0) {
			for (int count = 0;
                            (count < arrMethods.length && methodToExecute == null); 
                            count++) {
				Method aMethod = arrMethods[count];
				if (aMethod.getName().equals("getTaxRate" + strTaxMode)) {
					methodToExecute = Tax.class.getDeclaredMethod(
                                            "getTaxRate" + strTaxMode,
                                            methodParameters);
				}
			}	
		}
		if (methodToExecute != null) {
			Double rate = (Double) methodToExecute.invoke(
                            Class.forName("syrinx.cart.Tax"), 
                            args);
			if (rate != null) {
				return rate.doubleValue();
			}	

		}
	}
	catch (Exception exc) {
		Utils.reportException(exc);
		return 0;
	}
	return 0;
}

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

rjmccall posted:

Impressive, particularly since that entire thing is just:

code:
private static double getTaxRate(String strTaxMode, ServletContext application, HttpServletRequest request, String strPostalCode) {
  if (strPostalCode == null || strPostalCode.length() == 0)
    return 0;	
  try {
    Object[] args = { application, request, strPostalCode };
    Class[] argClasses = { ServletContext.class, HttpServletRequest.class, String.class };
    Method m = Tax.class.getDeclaredMethod("getTaxRate" + strTaxMode, argClasses)
    if (m != null) return ((Double) m.invoke(null, args)).doubleValue();
  } catch (Exception exc) {
    Utils.reportException(exc);
  }
  return 0;
}
(and even smaller if you're in Java 1.5)

It gets even worse when you know the context. There's only one method it will ever match.

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

Nippashish posted:

I think you mean !(!coherent != !true).

That has to be programming by permutation. I refuse to believe anyone deliberately writes code like that.

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

Zombywuf posted:

This is why Python can't have nice things.

I think this code is essentially the argument people use against Java getting closures. It's pretty convincing, I have to admit.

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

Mustach posted:

If someone being dumb is a convincing argument to you, then this thread is an argument against any language getting any feature.

Eh, that's going a bit far. I definitely think the population of programmers that "write" Java for a living contains an abundant amount of people that would "[be] dumb" with closures. Looks like Python is getting there too. Popularity brings morons. In droves.

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

Otto Skorzeny posted:

http://peter.hates-software.com/2004/08/20/6550cefa.html

GCC's option flags are a horror, although of lesser magnitude than GCC's internals and much of glibc

hey it's the elvis operator!

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

rt4 posted:

People do it because it's really fast and really easy. To me it makes sense, even for a small office.

Where I work my apps get used by people with iPhones, Blackberries, Apples, Windows, and Linux. I only need to write one decent version of a web app and it works well on every platform. I've tried a little bit of GTK, Swing, and C#; but, I still find web applications easier to craft. It seems ironic really, since I usually use 4 different languages to get the job done.

The best tool for the job isn't necessarily just one language.

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

Otto Skorzeny posted:

For C or Obj-C, clang. For C++, nothing yet.

Is icc not any good now? I haven't written C++ in years so I'm dated but it used to be pretty good.

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

ColdPie posted:

pre:
if(0)
  //what
  printf("hi");
prints "hi". your if-statement is useless.

just for fun I ran this through both java and gcc and neither printed anything.

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

Zombywuf posted:

The real horror is spaces around braces.

I just got access to the source of an extremely expensive product and their coding style is Allman with bracespace. :smith:

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

nbv4 posted:

same goes for javascript

what interpreter? I just tried safari, firefox, ie and opera and none of them allowed the comment to interrupt "normal" parsing.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
:downs: Hey I've got an idea, let's make our urls seo friendly!
:allears: OOh what a good idea! But wait, we didn't use the link function for all our href's and I don't wanna go back and edit my poo poo spaghetti code!
:downs: No I got this, see if we capture all the output and then push it through this:
code:
function callback($pagecontent) {
  // find all the href thatr are part of the <a> tag
  $pagecontent = preg_replace_callback("/(<a\s+[^>]*href=['\"]{1})([^'\">]+)([^>]*>)/", 'transform_uri', $pagecontent);

  return $pagecontent;
}
then no one has to do anything!
:allears: Sounds good to me! I'd hate to have to fix my poo poo!

...Later...

:mad: WHAT THE gently caress WHY IS THIS THING NOT REWRITING MY FORM ACTION URLS. *looks at seo code*
:mad: you motherfuckers

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
It's not really business logic so much as an implementation detail.

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

king_kilr posted:

Not a coding horror the way everything else in this thread is, but a friend of mine hates writing functions. I have no idea why, or what caused him to think this way, but he does. He often asks me things like, "Can I do this without writing an extra function?", and I don't get it. Luckily he's still a student, maybe they can beat it out of him.

This is the guy who wrote oscommerce's admin/categories.php:
code:
$ wc -l categories.php 
    3163 categories.php

$ grep 'function' categories.php | wc -l
    16
Well it looks like it has 16 functions, maybe each one is 150 lines.

Too bad they're all javascript functions, and half those lines are comments. :(

I hate working on that file.

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

Dijkstracula posted:

just make all identifiers uppercase and disallow underscores, and mandate spaces around '=': problem solved :pseudo:

Python? Ruby? Throw that poo poo out the window, it's time for a marriage of Bash scripting and FORTRAN 77 :f5:

Weak, JCL for life. Significant whitespace and hard to distinguish characters weed out the scrub tier pretty quickly.

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

Lexical Unit posted:

Your tax dollars at work folks (if you're American that is).

Can I work there? I promise I won't ask retarded questions about hash maps.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
Ah well, worth a shot. I'm the only one left after the last round of layoffs so there's no one left to ask non-retarded questions.

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

HFX posted:

Couldn't he just use a list to do the same thing, thereby forming a tuple?

I always end up having a generic class called Pair for just this reason.
Usually something like this: http://www.ideograph.com/content/generic-pair-java

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

HFX posted:

Yep the only problem I'd have with that is storing the time as a double. It would be better to have it as a packed Integer.

That reminds me of php's microtime() function. Goddamnit whoever wrote that is a cocksucker.

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

Janin posted:

I propose a new phrase "ozark bugs", meaning a bunch of errors which combine to mostly work.

Just spent four hours disentangling a mess of this; every time I fixed one error the system stopped working because another broken part of it had (by coincidence) worked only with the previous bug.

This is why I stopped fixing things. Subtly broken implementations get broken even more when you fix them.

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

adrenaline_junket posted:

I know this was from last year, but if its .NET Endeca is your answer

Man Endeca is loving expensive, just use Lucene unless you need all that marketing jazz.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
Our e-commerce app allows people to delete their order record information out of the table, just a click of a mouse away and "DELETE FROM ORDER WHERE id=?" gets run. It's not archived anywhere or anything. I just had to piece together a guy's cart from weblogs. :(

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

Janin posted:

FGPA

You've used this acronym twice, but do you really mean FPGA or is it a new acronym?

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

dancavallaro posted:

Don't tell that to whoever wrote that code, because he'll wrap every single line in his program with

code:
try {
   // everything!
} catch (OutOfMemoryError e) {

}
You never can be too careful!

Well you probably should gracefully handle OOM scenarios by reporting it. Although at the point you run out of heap I think the behaviour of the JVM becomes undefined.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
Niche markets tend to have REALLY poo poo programs because the top players are all "organically grown" solutions built by professionals in their fields trying their hand at playing computer programmer.

poo poo even low-to-mid sized e-commerce software is like this, I loving hate it.

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

ErIog posted:

I'd always heard this and known this. I just didn't think it would be quite this bad. I could take a bug here or there. I could take some extra rigidity in the amount of customization allowed within the systems. It ends up being just really baffling stuff like applications developed on platforms they're completely not suited for.

There's a weird database app we use for advertising that would be a million times better as a web app. Yet, it's a Windows app that interfaces with an on-site database, and is completely broken because of it. Just getting reports out of it is a nightmare.

The magazine CVS app I talked about, meanwhile, was developed mainly as a web app despite the fact that 99% of the time 99% of users are going to be interfacing with it through custom plugins in Adobe CS. That's why they decided to develop it in PHP.
Could probably plop a webservices/REST front end on it and it would be abstracted away. I've done that with lots of success when I needed to interface with a piece of poo poo from another piece of poo poo.

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

crazyfish posted:

Even worse than that was that I used to work on a project where the coding style required ENTER_FUNCTION() and EXIT_FUNCTION() macros on every method. Even if we wanted to instrument something with these, we could have used an AOP framework and did the whole thing in about 10 lines rather than the horrible code (and logging) diarrhea that ensued.

We used to have this nonsense along with making sure we named each class with a public static String MODULE.

A good bit of civil disobedience, mixed with claiming control of the SVN repo and strategic layoffs got rid of that horse poo poo real fast.

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

tef posted:

I wasn't 'allowed' to change it for four months or so.

That's the best part.

"Listen, you're doing everything totally the wrong way."
"I know but we're not going to change it now"
"Why not, it'll take me 15 minutes to set up"
"Because I said so"
"Please retire :("

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

Wheany posted:

Yeah, this. You really should learn them, and they're really not that hard. They have applications other than programming too.

:mmmhmm: Hey baby, s/your pants//g
:nyd: gently caress off, nerd

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

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
code:
        private boolean processFulfillmentData(ServletContext app, HttpServletRequest request) {

                boolean processedAllData = true;
                boolean processed = false;

                String localPath = request.getSession().getServletContext().getRealPath(FUL_LOC_PATH + FUL_FILENAME);
                String line = "";

                try {

                        BufferedReader in = null;
                        FileInputStream inp = new FileInputStream(localPath);
                        if (inp != null) {
                                InputStreamReader iReader = new InputStreamReader(inp);
                                if (iReader != null) {
                                        in = new BufferedReader(iReader);
                                        if (in != null) {
                                                boolean parsed = false;
                                                int currentOrderNum = 0;
                                                Vector fItems = new Vector();
                                                while ((line = in.readLine()) != null) {
                                                        // gather all line items from the same order number
                                                        FulfillmentItem fItem = new FulfillmentItem(app, request, line);
                                                        if (fItem.valid()) {
                                                                if (fItem.getEntOrderNum() != currentOrderNum) {
                                                                        // new entOrderNum found; process current order
                                                                        if (currentOrderNum != 0) {
                                                                                processed = processFulfillmentItems(app, request, fItems);
                                                                                if (!processed) {
                                                                                        processedAllData = false;
                                                                                }
                                                                                fItems = new Vector();
                                                                        }
                                                                        currentOrderNum = fItem.getEntOrderNum();
                                                                }
                                                                fItems.add(fItem);
                                                        }
                                                        else {
                                                                Utils.logError(MODULE, "Fulfillment item invalid: [" + fItem + "]");
                                                        }
                                                }
                                                if (!fItems.isEmpty()) {
                                                        processed = processFulfillmentItems(app, request, fItems);
                                                        if (!processed) {
                                                                processedAllData = false;
                                                        }
                                                                       if (currentOrderNum != 0) {
                                                                                processed = processFulfillmentItems(app, request, fItems);
                                                                                if (!processed) {
                                                                                        processedAllData = false;
                                                                                }
                                                                                fItems = new Vector();
                                                                        }
                                                                        currentOrderNum = fItem.getEntOrderNum();
                                                                }
                                                                fItems.add(fItem);
                                                        }
                                                        else {
                                                                Utils.logError(MODULE, "Fulfillment item invalid: [" + fItem + "]");
                                                        }
                                                }
                                                if (!fItems.isEmpty()) {
                                                        processed = processFulfillmentItems(app, request, fItems);
                                                        if (!processed) {
                                                                processedAllData = false;
                                                        }
                                                }
                                                in.close();
                                        }
                                        iReader.close();
                                }
                                inp.close();
                        }
                }
                catch (Exception e){
                        Utils.logJobMgr(MODULE + ".processFulfillmentData()", "*** Error reading file: [" + localPath + "], exception=[" + e.getMessage() + "]");
                        processedAllData = false;
                }
                return processedAllData;
Yup, that's the web application servlet context and request being passed in. To a job. That runs via Quartz.
Also, processFulfillmentItems is even larger than this and has around 15 exit points.
gently caress.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
code:
ubuntu@domU-:~$ php
<? echo "100{1}" == 100; echo "\n"; ?>
1
ubuntu@domU-:~$ php
<? echo "100 1" == 100; echo "\n"; ?>
1
FUUUUUUUUUUUUUUUUUUUUUUUUUUUCK PHP

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

b0lt posted:

code:
<?php
$x = 'foo';
$y = 0;
if ($x == true && $y == false && $x == $y) {
   echo "what";
}
?>
Equality isn't transitive in PHP :downs:

edit: or for that matter, symmetric

I think in this case it's not about the properties of == as much as a matter of php taking liberties with what a number is when its native form is a string. Once it encounters a non-digit character, instead of saying "welp this isn't a number, not equal" it apparently says "welp, ran into non-number, the rest of this string doesn't matter".

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

Monkeyseesaw posted:

This is why regexes themselves are the coding horror.

No way. Regular expressions are good tools. The coding horror is people using them to solve every problem relating to string processing they encounter.

Adbot
ADBOT LOVES YOU

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

Monkeyseesaw posted:

I'm being facetious. Regexes are obviously extremely useful but it's remarkable how much trouble people have with them unless you're working with them literally every day. If you were trying to invent a syntax that was scientifically designed to be impossible to remember or keep in your head at once you couldn't do much worse than the standard regex syntax. It's like something invented by an evil robot.

APL wins that particular award I think.

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