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
pigdog
Apr 23, 2004

by Smythe

Plorkyeran posted:

Luckily here we have a policy against empty catch blocks!


Is this a trick post because that's not the biggest problem here.

Adbot
ADBOT LOVES YOU

pigdog
Apr 23, 2004

by Smythe

Zombywuf posted:

Also, found this on reddit, optimisation on modern CPUs is a horror unto itself http://stackoverflow.com/questions/8547778/why-is-one-loop-so-much-slower-than-two-loops

:psyduck:

Reminds me of one of the first BASIC programs I wrote as a 11-year-old. I can't even remember the syntax of the language, but the gist of it was like this:

code:
10 initialize_graphics
20 x = rand(screen_width)
30 y = rand(screen_height)
40 color = rand(number_of_colors)
50 putpixel(x, y, color)
60 GOTO 20
Can you guess what the output was?




It should have "snowed" randomly colored pixels, but in reality the pixels developed on the screen clear, diagonal, bands of color like this: "///". It totally boggled my teacher's mind. :smug:

pigdog
Apr 23, 2004

by Smythe
That's very interesting/scary.

pigdog
Apr 23, 2004

by Smythe
Yeah everyone like a good flying bear video, but for a game of such (indeed unprecedented) scale, Skyrim is remarkably low on bugs and doesn't have anything to do with this thread. I think I saw like 2-3 serious bugs in 140 hours of my playthrough.


For content, I had a task of fixing an order management system recently. Made by one of the biggest software houses in the region while at it. They put it together using the same component they'd usually use to display tables of 0-50 rows, nd of course their clients didn't bother to check how it would act if the number of rows were 100k+.

So every time the user opened the page, the system
1) read from the database into RAM every row of the orders table
2) read from the database into RAM every row of the products table
3) read from the database into RAM every row of the customers table
then happily combined, ordered and filtered them as nice Java lists. Repeat the same procedure every time the user clicked anything on the page. :suicide:

pigdog
Apr 23, 2004

by Smythe

Look Around You posted:

This kid in my class asked me a couple days before the project was due (and a day or so before the final) if function parameters in C were passed by copy or not :eng99:

Correct me if I'm wrong (I never actually got around to learning C), but isn't the answer "either way you like"?

pigdog
Apr 23, 2004

by Smythe

Optimus Prime Ribs posted:

Everyone has their preferred way to write code.
But why should I be penalised for not conforming to the professor's preference?

It's not the biggest deal in the world, but the professor does have a point. You or some other dev might comment out or flat out delete the if statement, while forgetting about the bool gonnaLoseMarks = true;.
code:
// if (someVariable)
    bool gonnaLoseMarks = true;

if (someOtherVariable)
{
    bool gonnaLoseMarks = false;
}
The code would still be valid and compile, so it could introduce a hard-to-notice bug. If the curvy braces weren't used in such dumb style and start at the same line as if, that would make it harder to accidentally break it.

edit: Actually, depending on language it could make an even bigger mess if bool gonnaLoseMarks = true; was commented out instead. Something like

code:
if (someVariable)
    // doSomethingMeaningless();

doReallyImportantStuff();
The behavior of the code changes completely.

pigdog fucked around with this message at 22:04 on Mar 24, 2012

pigdog
Apr 23, 2004

by Smythe

Internet Janitor posted:

"At age 59, every programmer has the indentation style he deserves."

edit: Stallman is still perhaps outclassed by "Eastern Polish Christmas Tree Notation"

I don't know about braces, but I can dig the assignment operators being lined up. Looks kinda neat. :)

pigdog
Apr 23, 2004

by Smythe

Strong Sauce posted:

Did they seriously hard code every special offer code they have?

I hope not to sound like a contrarian jerk... But aside from general badness and not putting start and expiry dates in the code :doh: it's not necessarily a bad idea to hard-code promotions like that, depending on circumstances. Making a nice administration UI for something like that an order of magnitude more work. If an offer is complex, then making it configurable is even more complex. If it's a small company, the number of offers and options are limited enough to have a grasp of, and it's easy to deploy new versions, then it may very well be easier to tell the VB programmer to update the code and redeploy. As opposed to spending a lot more resources, and dealing with a lot more integration, security and maintenance issues, to develop an interface for non-technical people who may end up needing the help of technical people regardless. At the very least they seem to have some code reuse going on, and have the offers separated into distinct methods/objects. Come to think of it, that code could look far worse.

Maybe I'm just jaded because the core "god" system in my company is extremely configurable, and all sorts of cool offers can be created on the fly, but the code itself is horrible and we're reliant on a subcontractor for more than a decade to keep the mess together. The accomplishment of the year was to get all that PL/SQL code finally on version control. :hurr:

pigdog
Apr 23, 2004

by Smythe

Sulk posted:

http://pastebin.com/WEBKaCWK

I hope I'm not crazy.

Come to think of it, this is absolutely a textbook case of code that needs refactoring, such as...

- introducing constants because gently caress me, those numbers
- sort those constants (numbers) out to bring out actual business logic in human readable fashion
- get rid of global variables
- ... wait what, these aren't just global, but global session variables? :gonk:
- Call <whateverDiscount>(Session("key"), pIdDbSessionCart) repeated a million times means abstraction that simply glares in your face
- which first demands refactoring static functions into object and methods
- and there's ever been a chance to split a piece of code up into meaningful parts that do one thing, then stuff like
code:
...
        End Select
End If
                                                                                   
'then, check stored session key code
'add key code specific offer functionality
....
is as big of a hint as there can be.

Etc.

However, I don't hate that piece of code. There are some good things in it. I like how they've used nice and meaningful function names, and have grouped up offer-specific functionality in them. So for all its faults and obsession with offer codes, the code, and the business logic it's trying to convey, is almost readable even at this state. With a good refactoring it could probably flow rather nicely.

Meanwhile, since the offers are separated into methods that work on (presumably) the shopping basket object, they can contain arbitrarily complex rules. Not just static discount of x% or $x, but stuff like "on Fridays offer every 3rd item free to all grocery items as long as the basket has a Pepsi in it, but only once a hour".

The biggest functional deficiency seems to be the lack of automatic expiry and application of offers, which would apparently be clumsily solved by deploying new versions whenever anything changes.

edit: Come to think of it, the functions implementing the discounts, such as xpTillerDiscount50(), may actually include the relevant time constraints in them, and only do anything if the offer isn't expired.

pigdog fucked around with this message at 16:30 on Mar 29, 2012

pigdog
Apr 23, 2004

by Smythe
I was trying to understand what the code even does, but my mind started to wander off with all the anal1.put() and anal2.put() lines.


edit: Have to say, putting a test suite in the main[] method of a class is a pretty novel idea. Pretty much exactly like writing real unit tests... except for the part where the user has to verify all the results manually, instead of like, having the computer do it. :monocle:

pigdog fucked around with this message at 22:38 on Mar 31, 2012

pigdog
Apr 23, 2004

by Smythe

Suspicious Dish posted:

The anal1.put and anal2.put lines are just test data for the main function.
Oh. :saddowns:

:flaccid:

pigdog
Apr 23, 2004

by Smythe
Yeah, it's a pretty legit coding horror.

I mean, why would anyone really need such a data structure with such a lookup scheme in the first place? I bet the code that uses that class looks no better.

It was mentioned that performance is a problem, so presumably the actual FancyArray objects are fairly large. Where does the data it is supposed to parse come from?

If the data set is reasonably small, as in it has to fit in memory like a FancyArray would, then why isn't it represented as sensible objects?

If the data set is large enough, then why isn't it stored and queried from a database, and regardless, represented as sensible objects in the code?

It's like, whoever wrote this knew they needed some hierarchical way of storing and accessing data, but didn't really trust this newfangled objects, collections, and encapsulation malarkey.

pigdog fucked around with this message at 06:36 on Apr 1, 2012

pigdog
Apr 23, 2004

by Smythe
I don't know anything about Objective-C or Macs, so can't say what I know the context and what it's good for so well, but from where I'm standing it doesn't seem very neat, either. Perhaps it's a peculiarity of that language and environment, i.e. requirements to support easy scripting, and it can also be considered stable and explicit way of doing things that a developer can rely on and simply needs to learn. But not necessarily something that seems desirable to replicate in normal code or object models.

I mean, in Java you could make an object's fields public and explicitly read/write to them (or use reflection), and there are cases you might even see that as desirable (ie setting up unit tests), but you can also accomplish the same while maintaining encapsulation by setting them to default or protected scope instead of private, and having your unit test live in the same package as the code, though obviously in a separate file and directory.

Meanwhile, even if the class was optimized better, I can't quite imagine the problem to which I'd say "yeah, the best way is to use a FancyHash to do this".

pigdog fucked around with this message at 17:10 on Apr 1, 2012

pigdog
Apr 23, 2004

by Smythe
Seeing as he has 3700 viewers at the moment, I suppose plenty of people do.

pigdog
Apr 23, 2004

by Smythe
His game is a very good example though of a quality product. Code quality isn't in fact about how good the code looks, how reliable it is or whether it runs as fast as it could -- it's about whether people would want to use it. In this case, whether they'd want to play the game. Even it (in comparison) runs like rear end and is written badly, the game has still sold millions of copies and is by any means an unabashed success.

The fact is that people don't care about the code or the performance being terrible, or at least don't care enough not to play the game. Other developers may look at his code and find it terrible, but it doesn't matter while he's laughing all the way to the bank.

That's a serious lesson to consider. People with different background put different importance on different aspects of software. Things that a developer may consider important, such as cleanliness of code, reliability, etc, may but may also not necessarily be what the customer, or the users consider important. Don't get me wrong, I love fully tested, clean and bulletproof code, but there may be cases where making tradeoffs is the right thing to do.

pigdog
Apr 23, 2004

by Smythe

quote:

Nobody here is lamenting that Notch did it first or that we could do it better. It's coded badly. It is a thread about bad code. Therefore, we are talking about it. It's the same thing for PHP. And RMS. Just because someone did something good/cool/popular/etc does not make that product immune to criticism.
Absolutely, but the criticisms here don't really matter. Minecraft is a success and Notch made millions, because he was able to put the product out there and the users liked it, not because the code he produced was brilliant. The time he spent on his code produced a helluva lot of value. From the perspective of Notch and developers who'd like to be as successful as him, he did it right.

quote:

'Fitness for purpose' is not the same thing as quality. Consider PSN, before last April. Millions of people wanted to use it. Sure, Sony was transmitting and storing unencrypted credit card numbers, but nobody cared - information security just wasn't important to their customers. Hell, even after the breach, most people blamed the "hackers" for everything. By your definition, PSN was a very good example of a quality product. Do you think Visa and Mastercard agree with you?
I'm not familiar with PSN but isn't it something that Playstation users have to use for multiplayer and communication functionality in their games (which is what they actually want to use), rather than something they have a choice of using?

In any case, if we were to say PSN was one of the many gaming and communication networks available and there was real competition, then the quality would include top notch security, as security of credit card information would certainly be a huge factor in choosing a gaming network. Hell, it's hard to imagine a situation where security over handling credit card information wouldn't be. If you were to build a network like PSN and you couldn't make it produce value, because Visa and Mastercard would deny you and/or the customers would sue the crap out of you, then no matter how gold-plated your code is, you are doing it wrong. On the other hand, performance of a game like Minecraft is provenly a smaller factor than fellow developers may think.

pigdog
Apr 23, 2004

by Smythe

quote:

Because clearly if something's successful it's automatically perfect, right?
From Notch's perspective, counterintuitively, yes. It proves, with cold hard cash to back it up, that the faults in his game and coding style are relatively insignificant.

Ultimately you don't code something like this for coding's own sake. Succeeding in writing software that people would buy is a higher level goal than writing perfect code. The latter is ultimately the means to attain the former.

pigdog
Apr 23, 2004

by Smythe
That's correct: if people buy your cheap and lovely candy and you're making profit, then you must be doing something right. McDonalds is a pretty successful company, wouldn't you agree? You're not running the factory for the candy (instead you could just go to a store and buy any candy you personally like), but as with any enterprise you're running it for profits.

But sorry for the derail.

pigdog
Apr 23, 2004

by Smythe

Look Around You posted:

I am not Notch. I am not speaking for Notch. I am speaking for myself. I don't give a drat whether or not he's making money off of it, it doesn't affect me one bit. I'm a lot more interested in theory than in making money anyway.


Again this is extremely presumptuous. Writing "perfect code" is more than just about becoming profitable or "successful". It's also a way to improve your knowledge and skills. Sometimes I'll put in 5 hours on school project that I could cobble together in 1 hour. Sure I would probably get the same grade, but doing that won't make me any better of a programmer.

If he's just out to make money, then fine, that's what matters to him, but that's not what this thread is about. This is not "Software Success: Post the produce that make you laugh (or smile)". I'm not even being glib. You're missing the whole point of this thread.

On the contrary, I'm perfectly aware of what this thread is about. Minecraft's success story in my opinion augments it brilliantly. Developers may get too caught up in quality and gold-plating that they don't realize, or forget, what's actually important: for the code to provide some value for someone. Personally, I'm totally obsessed with writing clear, optimal and bulletproof code with test-driven methodologies, but there's no way to argue with Minecraft's success. Something like Skyrim has been and has to be lovingly, skillfully and painstakingly crafted, but from the other end, noone would gold-plate or test-drive a shell script they would only use once. Notch has found his own sweet spot between speed, skill and quality, and even if it's not quite as well made as Skyrim or not quite as hacked together as a single-use shell script, he has succeeded and thus done it right in his own way.

pigdog
Apr 23, 2004

by Smythe

the ultimate PHP rant posted:

I have heard a great many stories about the PHP interpreter and its developers from a great many places. These are from people who have worked on the PHP core, debugged PHP core, interacted with core developers. Not a single tale has been a compliment.
:drat:

pigdog
Apr 23, 2004

by Smythe
You'd base your procedural generation on something else rather than buggy system-specific random, as in by definition unpredictable, number generation. Something you'd include as a part of the codebase for the game.

pigdog
Apr 23, 2004

by Smythe

The Gripper posted:

Reminds me of this:


It's not as funny as it could be, because Erlang is actually pretty awesome. :)

pigdog
Apr 23, 2004

by Smythe

baquerd posted:

Every so often explicit code jumps are useful, here's a fragment I recently used one in. While you can write this block in other ways, I like the flow better this way.

code:
  nextList:
  for (String key : thresholdMap.keySet()) {
    ArrayList<String> currAdditiveKeys = new ArrayList<String>(Arrays.asList(key.split("\\+")));

    if (currAdditiveKeys.size() > 1) {
      for (ArrayList<String> testKeyList : additiveThresholdKeys) {
        if (testKeyList.equals(currAdditiveKeys)) {
          continue nextList;
        }
      }
      additiveThresholdKeys.add(currAdditiveKeys);
    }
  }

I don't have a compiler at hand at the moment, so this is straight from the hip, but I think this could be written as

code:
for (String key : thresholdMap.keySet()) {
	ArrayList<String> currAdditiveKeys = new ArrayList<String>(Arrays.asList(key.split("\\+")));
	if (currAdditiveKeys.size()>1 && !additiveTresholdKeys.contains(currAdditiveKeys)) {
		additiveTresholdKeys.add(currAdditiveKeys);
	}
}

pigdog
Apr 23, 2004

by Smythe
If you're doing something with the XML, you'd almost certainly expect it to be in a particular format. You can define that format in a .xsd schema, afterall that's what they're for. It's still a good idea define a schema for the XML data format even if you use a generic parser of some sort, if only for testing and documentation purposes.

pigdog
Apr 23, 2004

by Smythe

Bhaal posted:

In terms of data format I wouldn't say XML is necessarily a terrible way to go in this case, BUT:

If these are being generated by the public, especially if the node structure your software is expecting is very dynamic and/or specific to its requirements, hand editing XML like that can be a real pain especially for end users. (That being said, I don't think hand editing in any format, JSON, YAML, or whatever will be any better in this situation). For instance, if your software encounters node N, say it needs at minimum child nodes X, Y, Z defined, and say it's parsing a user submitted a document with a Node N with only X and Y defined. Do you have a fancy system of defaults to fill in any gaps, or will your internal data structures be incomplete without Z defined externally? If the latter, you'll want to make it easy for them to spot and fix this.

One solution is you could offer a validator so they can quickly fix any mistakes right away. User generates the document, runs it through the validator (web tool or whatever), and it comes back with "Hey dummy! Node N at line 123 needs child node Z defined!".
That's why defining an XSD schema is a good idea. You can say in it that node N needs X, Y, Z and optionally Y, and if the XML doesn't have them, then it's simply invalid. You can publish the XSD and independently validate the XML (at least as far as the structure goes) before submitting it. On the other hand, the code that makes use of such predefined XML format can be simpler and less defensively programmed. The schema kinda works as a contract/conformance test as such.

quote:

A better solution, though involves a lot more dev time, is to make an editor for them. It's on the fly validation as you can have the editor demand input where input is required, generate required child nodes and so on, so your user doesn't get lost in the weeds on your data structures. Also they don't have to worry about syntax or any of that meta data and instead just fill in the pertinent stuff. You could do this in a native app or make a page that builds out form elements with js/jquery/etc, submits to your server, and you feed them back the resulting xml. Note: I don't know how much use those xml documents will see from your userbase, though, so putting in the time to make a tool like this may not be an efficient sub-project to work on if you don't anticipate a lot of user generated documents. If 1 in 10 of your dedicated userbase will ever seriously dabble in it, maybe it's best to provide clear documentation & examples and leave it at that.
Well that's true; the end user would rarely be expected to hand-write XML in the first place.

pigdog
Apr 23, 2004

by Smythe

Janin posted:

Also, once you're in your handler, you'll have to spend several more milliseconds establishing database/rpc connections, loading/parsing templates, and generally doing setup work that a single-process server only needs to do once.
This. CGI performance is fine I guess if 1) you write your web apps in C and 2) they don't actually do anything. The difference in overhead between opening and reusing (or pooling) database connections is particularly obvious.

pigdog
Apr 23, 2004

by Smythe

Zombywuf posted:

I...

just...

I have no words.

Please do me a favour and never ever write anything that I might have to maintain, scrape, crawl or have any contact with in any way.

I'm sure you're trolling, but that's not very funny. And if you're not, then the last pages are just :psyduck:.

Zombywuf posted:

CGI is a perfectly good way of running code.
It's a lovely and useless way of running code that only exists because very long time ago it was the only way. All it has going for it is safety in memory management (barring bugs in the code itself) and ease of deployment, while for anything you'd want a website of 2010s to do it's a slow pain in the rear end. Interfacing with databases, keeping session information, the works.

pigdog
Apr 23, 2004

by Smythe
Speak for yourself, using languages other than English with computers used to be a lot bigger pain in the rear end.

pigdog
Apr 23, 2004

by Smythe

Golbez posted:

It's basically:
* Replace part of a string with something else.
* Using regular expressions, remove everything that's not a letter or single space from a set of strings.
** Most people simply go for /[^A-Za-z ]/, without realizing the single space part of the instructions.
Two or more spaces are simply two or more instances of single space placed adjacent to eachother. :geno:


quote:

This one is easy enough, using mktime(). Just provide the stuff getdate() gives you to it and run the returned timestamp through getdate() again, adding a day if wday == 0 || wday == 6. Since mktime allows days beyond the end of a month (which go into the next month) this is pretty simple even for a braindead solution I just came up with in 30 seconds.
Did the week start with Monday, or Sunday?

pigdog fucked around with this message at 19:26 on May 10, 2012

pigdog
Apr 23, 2004

by Smythe

Zamujasa posted:

(The other, more plausible solution is just turning all input to lowercase letters, but given the "security" of several large corporations these past few years, I suspect the worst.)

Pretty sure that's how they do it.

It's just a game password, and not brute-forceable (against their servers), so meh, reasonable enough.

pigdog
Apr 23, 2004

by Smythe
What if there are 500 items in the category, but the page is set to display only 20 of them at a time? What if some of the items don't have images associated with them?

Y'all should just get rid of the hardcoded and un-i18nable "Total Items:" and let #CatTotal refer only to the number.

pigdog fucked around with this message at 08:45 on Jun 6, 2012

pigdog
Apr 23, 2004

by Smythe

darthbob88 posted:

Apparently the site's set to display at least 40 items on a category page, so that's not an issue. AFAIK, all the products have images, so my solution would still work. They may be blanks reading "No Photo Available", but every product has an image. And of course it doesn't really matter anymore, since the new system doesn't care about how many items are in a category.
Both your solutions have unnecessary hidden dependencies
Your boss's:
- expects the string "Total Items: <number>" with no regard to i18n

Yours:
- expects every product to have an image
- expects every product to have one image
- expects products without images to have blanks
- expects said images to have ID of "qv_*" (though perhaps that's a firm specification?)
- expects the number of images per page to equal the number of items per category (all products to be displayed at once)
- presumes the question to be whether or not there were more than 20 items in a category, and the actual number to be irrelevant

If that's just one-time scrape, then cool, it doesn't matter terribly much. Yet I feel your original solution involves many more unobvious assumptions, each which have potential to introduce bugs and disparities if the context changed. Even on the link you provided, your solutions would provide different counts already.

pigdog
Apr 23, 2004

by Smythe

evilentity posted:

How the gently caress people conclude that 2000+ lines of same code with 3 variable things is a good idea? :psyboom:
If only we had these base things... or arrays/dicts at least.

Not that it couldn't be expressed better, but that code is very probably generated.

pigdog
Apr 23, 2004

by Smythe

Zombywuf posted:

This makes you sound like someone who has never used Perl.
Perl has a share of coding horrors as well. In 5.6.0 it introduced Unicode (or UTF8) support, which was in theory pretty great. Everything would have continued to work as usual, except there's support for weird characters to manipulate and match. Well.. except it didn't work too well. For starters

quote:

Unfortunately, there is currently no way to tell Perl that incoming data from an external file is Unicode; while you can write Unicode data out to a file, you cannot read Unicode data back in again. While you can work around this with tr///CU, it's obviously a serious shortcoming, which we hope will be addressed soon.

It was a horribly broken mess. In its quest for backwards compatibility and doing the right thing intuitively, it made guesses about the character set the text it manipulated was in. They weren't very good guesses. If you got tired of the brokenness, said "gently caress it" and tried to revert to previous approach of use bytes;, then external libraries (like XML parsers) broke in turn.

One of the greatest such "features" I wrestled with was when you got everything right and it started outputting a page in a correct encoding and everything was peachy... but upon inserting a substring or encountering some character it decided it had guessed wrong and changed the encoding on the fly. Had a fun time solving bug reports saying that half of some page displayed properly, but the other half of the page was in gibberish. :suicide:

They gradually improved the stuff and somewhere around 5.8.4 5.6.4 I think it got better. Thankfully I was over doing serious app development in Perl by then.

pigdog fucked around with this message at 21:23 on Jun 21, 2012

pigdog
Apr 23, 2004

by Smythe

shrughes posted:

Floating point for monetary values isn't necessarily a coding horror.
It's a fairly strong smell (Primitive Obsession) of a coding horror. Money isn't just a number. You can't handle monetary amounts the same way as any old floating point value, i.e. round them up and down by common math rules, and in many cases there are concepts such as currencies to keep track of. In most applications it's very appopriate to represent money with a dedicated class.

pigdog
Apr 23, 2004

by Smythe
C coding makes one p. mad.

pigdog
Apr 23, 2004

by Smythe
Most of the discussion here really stems from the fact that different people argue over rules which apply to different levels of the Dreyfus model. The rules that you'd set for a beginner or advanced beginner are different from these that apply for an expert.

For a 2-year-old the rule is simply "DO NOT TOUCH THESE WALL THINGS, OUCHY OUCHY".
For a 8-year old the rule might be, "Never touch or shove anything into the wall outlets except for proper plugs on things".
For an adult the rule may be "Don't mess around with the outlets except when you're sure you switched the power off at the mains".
The next level may be "Well you may touch one of the wires even when the power is on, as long as you're isolated from the ground and not touching any other wires"

Same thing for anything code-related. It makes better sense to offer the beginners concrete and hard rules, which they may grow out of, rather than trying to explain the intrinsics of electricity to a 2-year-old.

pigdog
Apr 23, 2004

by Smythe

Extortionist posted:

I came across something like this today, in some older code written by one of our more senior programmers that's still being used for live, production work:
Perl code:
@somearray = ( "this work has been updated", "updated",
               "this work hasn't been updated", "same",
               "this work is new", "new"
               # and so on
              );

$somearray_len = @somearray;
$counter = 0;

while ($counter < $somearray_len){
    my $var1 = $somearray[$counter];
    $counter++;
    my $var2 = $somearray[$counter];
    # do stuff
}
This was, by far, the sanest and most comprehensible part of the program.
Came for awesome perl horrors, left slightly disappointed. Sure he could have just gone for %somehash = @somearray and worked it from there, but hey, TMTOWTDI. Sane and comprehensible is a tall order for Perl programs in the first place.


quote:

Every time I look at this I am increasingly more appalled that this guy is apparently using an editor with a <35 character line limit.
A junior Java dev of ours came from a startup company (where he was senior), where the framework they were working with expected developers to edit Java code literally in a HTML textbox with that kind of line limit.

pigdog fucked around with this message at 10:46 on Nov 30, 2012

pigdog
Apr 23, 2004

by Smythe

Hughlander posted:

Could be worse... Could be
code:
public static void Main()
{
	try 
	{
		while(true)
		{
			Go();
		}
	}
	catch (Exception) { }
}

public static void Go() 
{
	// Entire application branches off from here
}

You could put actual exception handling code inbetween these { } at the catch statement, and for most programs, end up with excellently handled exceptions.

Adbot
ADBOT LOVES YOU

pigdog
Apr 23, 2004

by Smythe
This is a very nice article on how to use exceptions:
http://www.sysart.fi/news/9/37/Exceptions---the-big-picture/d,artikkeli

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