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
Color Gray
Oct 10, 2005
BARF!
I maintain a project that was full of plenty of horrors (the original author was...uh...), although fortunately most of them have been removed over time by either myself or our other developers. My favorite had to be this "pattern" (yes, it was used more than once) for processing rows:

code:
int i = 0;

foreach (var row in rows)
{
    ProcessRow(rows[i]);

    i++;
}
How should I loop over the rows...with a foreach loop? With a for loop and an index? Nah...I'll use both! :shepicide:

I mean, it's incredibly stupid, but at least it will still process the correct rows, right? Well, one time it looked like this:

code:
int i = 0;

foreach (var row in rows)
{
    if (/* some condition */)
    {
        continue;
    }

    ProcessRow(rows[i]);

    i++;
}
:cripes:

Adbot
ADBOT LOVES YOU

Color Gray
Oct 10, 2005
BARF!

Verloc posted:

Inherited yet another codebase of dubious quality. Why are users bitching about poo poo being broken constantly, data being corrupted, and not a goddamn thing showing up in the logfiles or system event log? What the shi...

oh.

I guess 'ignore them and hope they go away' is a kind of exception handling strategy. :cripes:

Yeah, at one point the project that I mentioned in this post was full of those. I once glanced at an old version of the code and nearly every function had its body surrounded with try { ... } catch (Exception) { }.

Color Gray
Oct 10, 2005
BARF!

Verloc posted:

'sup "Opened the solution and immediately regretted my decision" buddy. :stonk::hf::stonk:

Silent Catch Safari™ continues this week with more searching on variations of catch(Exception). So far I have found several examples of this noble beast majestically roaming the App_Code directory:
try{...} catch(Exception){throw;}
Yup, caught the exception! :downs:

Here's one of the best examples from mine:

code:
public string[] GetItems()
{
    try
    {
        List<string> items = new List<string>();
        items.Add("Item1");
        items.Add("Item2");
        // etc.

        return items.ToArray();
    }
    catch (Exception ex)
    {
        return null;
    }
}
:stonklol:

Color Gray
Oct 10, 2005
BARF!

On a related note, I once saw someone link to this "rebuttal" to that article:

http://forums.devshed.com/php-development-5/php-fractal-bad-design-hardly-929746.html

Except that they ignored the part where the author of the article himself ("Eevee") shows up and (very politely) shits all over his arguments. :laugh:

Fake edit: I forgot that the guy attempting the rebuttal also gave us such gems as "JavaScript is not a loosely typed language." :downs:

Color Gray
Oct 10, 2005
BARF!
This response from Hugo Mills was really good (emphasis mine):

https://lkml.org/lkml/2014/7/31/194

Hugo Mills posted:

Date Thu, 31 Jul 2014 11:11:16 +0100
From Hugo Mills <>
Subject Re: [PATCH] Remove certain calls for releasing page cache

On Wed, Jul 30, 2014 at 10:05:16PM -0400, Nick Krause wrote:
> On Wed, Jul 30, 2014 at 7:30 PM, Dave Airlie <airlied@gmail.com> wrote:
> >> This patch removes the lines for releasing the page cache in certain
> >> files as this may aid in perfomance with writes in the compression
> >> rountines of btrfs. Please note that this patch has not been tested
> >> on my own hardware due to no compression based btrfs volumes of my
> >> own.
> >>
> >
> > For all that is sacred, STOP.
[snip]
> > But if you want to work on the kernel, this isn't the way to do it, and
> > nobody will ever take a patch from you seriously if you continue in this
> > fashion.
> >
> > Dave.
> Dave ,
> Seems I need to have tested this code first.

You've said this before, having made exactly the same error (not
testing a patch). Yet you do it again. You seem to be ignoring all the
advice you've been given -- or at least not learning from it, and not
learning from your experiences. Could you please, for half an hour or
so, stop thinking about the immediate goal of getting a patch into the
kernel, and take a short while to think about your process of
learning. Look at all the advice you've had (from me, from Ted, from
others), actually understand it, and consider all the things you need
to do which *aren't* hacking up a lump of C. Actually learn these
things -- have them in your mind all the time.

I would appreciate it if you could actually engage with someone
(doesn't have to be me) about this -- why are you ignoring the advice?
Is it because you don't understand it? Is it because you think you can
cut corners? Is it because you're concetrating on the code so much that
you're forgetting it?

The main thing you're doing which is making people angry is not
because you're submitting bad patches (although you are). It's because
you're not listening to advice, and you're not apparently learning
anything from the feedback you're given. Your behaviour is not
changing over time, which makes you look like a waste of time to all
those people trying to help you.


Hugo.

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