AGH. Silly mistakes

Thursday, March 18th, 2010 04:42 pm
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
[personal profile] afuna
In my attempt to conquer Bug 2344: Default View/Default filters should be default when adding from hover menu, I wrote this line of code:

$success ||= $filter->add_row( userid => $u->id )

What I thought it said:

* add this user to the filter
* once you've added the user, check whether it was successful, and keep a running tab on the status so you'll know in the end whether everything succeeded or not

What it was actually saying:
* once you've successfully done one thing (e.g., added the user to a filter or subscribed to that user), we're done. We don't need to do anything else (in this case, adding a user to the filter).

So now I've rewritten it more properly as:

$success = $filter->add_row( userid => $targetu->userid ) && $success;

(I got the boolean logic initially wrong too *rueful*)


This was an entire afternoon's worth of frustration (whyyyyyyy isn't it adding the user to the filter? Why doesn't it print out any of my warn statements within add_row? I didn't realize I wasn't calling it at all), solved with one of those flashes of insight you get when you get up and grab a glass of water and happen to reread your code when you get back.

Date: 2010-03-23 03:52 pm (UTC)
pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)
From: [personal profile] pne
it's not like you can know what I already know, or don't, or am assuming

*nods*

And thanks for your last paragraph.

I had more to say but I couldn't think of a good way to express it.

<3

Date: 2010-03-25 08:58 am (UTC)
pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)
From: [personal profile] pne
WRT explaining, I think the hardest thing about explanations is that sometimes they *don't stop*. [...] lately I've been having a run of people explaining things to me unnecessarily and just not stopping

If I ever do that, please tell me explicitly -- I don't always notice social cues, and not out of malice, either. Being "polite" in such a case would probably not help either of us.

thank you again for sharing your knowledge/ insight

I'm glad you found it helpful.