HNHacker News
TopNewBestAskShowJobs

urbanautomaton

138 karma · joined June 28, 2011

All-purpose developer and C++ refugee, currently molesting Ruby on behalf of Tribesports.
submissionscomments
urbanautomaton··on Ben Goldacre: Here’s the foreword to my new book, Bad Pharma
> If it's so easy to fix the system, people would have already done it.

This doesn't follow at all. The difficulty of fixing a system is just one possible reason it might remain as it does; regulatory capture is another, as is well-financed lobbying at the legislative level.

Pharmaceutical companies have a very clear financial interest in seeing as broad as possible use of their products, and demonstrably have the lobbying reach to forcefully advance this interest. If reform of medical trial data regulation is not a vote-winning platform (and it's hard to argue that it's uppermost in many voters' minds), then it's perfectly plausible that a broken system would persist despite the availability of easily-implemented solutions.

urbanautomaton··on Rails Testing with Factory Girl
My preference is to have the base factories set everything that is needed for the generated record to be valid, and nothing more. If your User model validates the presence of the account, then the account association should be set - if not, it shouldn't. Otherwise, FactoryGirl.create(:user) is going to provide you with an unsaved, invalid record, which would certainly be surprising to me if I were using that factory for the first time. If all you want is a consistent set of initial attributes, then define a constant USER_ATTRIBUTES somewhere with a hash of values, and pass that to #new - using factories for this purpose is a bit sledgehammer/walnut.

I agree that excessive association building can get out of hand (and the latest version of FG even allows you to subscribe to factory events just so you can work out what the hell your test suite is building - a sure sign that you've lost the ability to reason about your tests if ever there was one), but completely abstaining from building associations seems to remove more or less all of the attraction of using factories as a fixture replacement in the first place.

All of the above applies only to integration/acceptance tests, though, where factories-as-fixture-replacements are at least arguably justifiable; my recommendation for unit tests is "don't use factories at all."

urbanautomaton··on Rails Testing with Factory Girl
Remember to ensure that your build strategy is set on all associations if you want this to work, e.g.

  FactoryGirl.define do
    factory :user do
      association :account, :strategy => :build
    end
  end
Otherwise when you build a user, the account association will still get persisted to the database.

Even if you do this, though, you're still spinning up a whole network of real objects in what is supposed to be a unit test.

urbanautomaton··on Rails Testing with Factory Girl
If I could upvote the parent any harder, it would hit orbit.

If you need a complex network of collaborators to test a method, the answer is not to obscure the creation of those collaborators, it's to refactor so that each object talks only to its immediate neighbours, and then stub the heck out of them. If it absolutely has to be something that acts like an ActiveModel, then use mock_model().

urbanautomaton··on Rails, callbacks, workers, and the race you never expected to lose
Ah, technically correct - the best kind of correct. :-)

Anyway, I agree with pretty much everything you say. As I mentioned elsewhere in this thread, we've gone down a pub-sub event system for handling our generic post-action tasks. The controller announces a :create_user event, and any interested listeners can respond appropriately. And yes, one of the biggest benefits of this has been the ability to test that event-handling logic in isolation; stubbing and mocking collaborators, and generally having the sort of testing fun you're normally not supposed to have with Rails.

urbanautomaton··on Rails, callbacks, workers, and the race you never expected to lose
I'll post something about it soon - while the changes were wide-ranging for us (because these post-action tasks were initially scattered throughout our app), the extra infrastructure required was really pretty minimal. Most of the actual time spent in this refactoring was writing new tests for code that we'd previously been unable to practically test.

In the meantime, the pub/sub setup we've got is pretty similar to the one presented a little way down the following article:

https://www.theagileplanner.com/blog/building-agile-planner/...

Our listeners sit completely separate from the controllers, though, and we're not using them for anything like handling controller response logic (I'm not sure how I feel about that, although the idea is certainly interesting).

urbanautomaton··on Rails, callbacks, workers, and the race you never expected to lose
He's not using the model to render the view, though, he's using it to queue up a future asynchronous request to the relevant mail "controller".
urbanautomaton··on Rails, callbacks, workers, and the race you never expected to lose
Absolutely agreed - better to make these things explicit somewhere rather than having your business logic implicitly handled by something directly coupled to your persistence layer (with the exception of data integrity tasks as mentioned by danenania).

As a sort of half-way house between using lifecycle callbacks and sticking everything in the controller, I've just moved the main app I work on to a pub-sub event system, which is working out quite nicely. Controllers or mutator methods no longer handle post-action tasks, they just announce what they did, and any interested listeners can act upon the event announced. This way we can have a listener that handles (for example) all post-action emailing, and we can test the logic for that in isolation. Controller logic is cleaned up too, so testing them becomes easier. On the flip side we have to write more comprehensive integration tests to make sure our listeners are all hooked up correctly, but it seems like a pretty good trade-off so far.

Enjoyed the OP nonetheless, though - I didn't know about ActiveModel#previous_changes, that's pretty nifty to have.

urbanautomaton··on Learn Regex The Hard Way
Perhaps a footnote could mention that this style really is possible in modern regexp implementations? I see chapter 20 is inked in to cover verbose regexps with comments (which is great!), but the current text could give the impression that it's a purely imaginary feature.
urbanautomaton··on Switching Sol Trader from Ruby to C++: one week on
Right. But that's not the only reason to write tests, and presumably if your tests were giving you false positives, you'd want to note and address that. If "are my tests telling me when my software fails?" is a valid question to ask oneself, surely so is "are my tests telling me when my design is flawed?"

Of course, you might not believe that design feedback is an important motivation for writing tests, which is absolutely fine, but then the issue isn't that the OP is "focusing too much on process and methods" - he simply has different processes and methods to you.

urbanautomaton··on Switching Sol Trader from Ruby to C++: one week on
> For example it's paramount to test your software, but whether this is TDD or not is secondary.

If you don't examine your motivations for writing tests, and evaluate whether they're being fulfilled, how do you know their necessity is paramount?

urbanautomaton··on Motorola secures Europe-wide sales ban on iPhone, iPad
Is it common practice to register anonymous accounts to explain why you've downvoted someone? "anonmouse" doesn't have sufficient karma to downvote anything, so clearly isn't your regular account. You appear willing to downvote others over inconsequential nonsense, but won't risk your own karma over it. This doesn't seem entirely in the spirit of things, I have to say.

> I'm not trying to be a dick about it-- and I hate to clog up the comments section with a garbage comment like this one...

Next time, then, consider doing neither.

urbanautomaton··on Why not just use an IDE if you want IDE features?
I was responding specifically to the somewhat alarming claim that faith in the operation of one's IDE is a substitute for regularly running tests. I wasn't denying that automated refactoring tools are nice to have; they obviously are.

Regardless, I don't really think that the examples you give have much to do with the IDE vs (editor+plugins) debate; they're to do with the amenability of one's language to static analysis. Certainly code modification features are available to statically typed languages that aren't available to dynamically-typed ones (and this may explain why users of the latter are less drawn to IDEs), but there are compensatory benefits to using a dynamic language. Let's not get into that one, though, eh? One eternal flame-war per thread is probably sufficient. :-)

urbanautomaton··on Why not just use an IDE if you want IDE features?
> Being able to trust the tool to have made the change correctly is invaluable in this process; it avoids a full unit test suite run after each step, and significantly speeds up major refactoring work.

If your unit tests aren't fast enough to run the relevant set after each change, you're most likely writing poor unit tests. And if you need to re-run the whole test suite after making a localised change that doesn't alter behaviour, then either your code is too tightly coupled, or your tests aren't really unit tests, they're integration tests. Maybe both.

I also have to wonder at the sort of attitude that prefers to have faith in Visual Studio or Eclipse, rather than in tests that specify the code's behaviour. And how do you know you didn't mess up using the refactoring tool? Faith in your IDE's correct operation is no substitute whatsoever for checking your code's correct operation.

This whole argument is ludicrous, anyway. A text editor that's been enhanced with powerful plugins is, as far as I can see, an IDE. My Vim setup has project navigation, method completion, build integration, you name it. I could even have automated refactoring if I felt the need:

https://github.com/ecomba/vim-ruby-refactoring

In the end we all use editors with high levels of language-awareness, and varying levels of project- and build-awareness. Some of us put them together ourselves, some of us installed a complete package. Judaean People's Front, anyone?

urbanautomaton··on Google+ Opens to All
Others have pointed out that the SLA isn't an issue. As for the separate service thing, there was a recent transition that was supposed to rectify this, merging the Apps and regular accounts services. The page you link to is about the need to remedy clashes caused by this transition.

During this process, users who maintained secondary accounts were encouraged to merge them into their Apps account. I used to have two accounts, one for Apps services on my own domain, and another for things like Reader. I now only have one, my Apps account, because the accounts clashed and had to be merged.

So the doubly galling thing about this Google+ farrago is that a) it proves that the accounts transition did not in fact stop Apps accounts being second-class citizens, but also b) most of us no longer have our secondary accounts, because we merged them at Google's insistence.

Add to this several years of teeth-grinding annoyance at the incompatibilities between Google Apps and the rest of the Google world, and, well, that's why people are complaining. :-)

urbanautomaton··on The Drupal Crisis
There is not a single mention of either unit tests or "reusing components in other frameworks" in the original article. Did you read it?
urbanautomaton··on Steve Klabnik's response to critiques of his Ruby OOP post
You should try to avoid subverting a framework's conventions if you're going to use it, sure, but Rails' helpers seem more like an absence of convention. They're a dumping ground for methods that are crying out to be properly structured. Surely not even the most fervent Rails advocate would claim that it is complete and unimprovable.

Every single helper module is mixed in to every single view instance, no matter how irrelevant it may be. There's therefore no reason to carefully choose where to put your helper functions, because they're all available, all the time. This means that a new coder coming along has no idea where to look for helper functions that might be relevant to a particular view he's creating - they could be in literally any helper, or even be helper-ified controller methods. This in turn means you end up with duplicated functionality, orphaned functions, and obsolete cruft stinking up the joint.

As a result, any even slightly professional team must develop their own conventions regarding the placement of helper functions. These conventions need to be communicated somehow, and how better to do that than through the code itself? Once you've got a pile of helper functions that are bound by a common cause, why not give that cause a name?

urbanautomaton··on Rate our startup: Tribesports - a social network for sportspeople
Hi athst,

Thanks for your comment and questions. We went with "sportspeople" because our research showed it was regarded as meaning "people who do sport" in the most places - in the UK, for instance, "athletes" is often (but not always) interpreted as referring specifically to people who do track-and-field athletics.

You're quite right, we're not aiming to be a sports fan site - we're very much focused on the sportsperson/athlete. We're not really a Meetup-for-sports, though (although obviously it's great if our members find new sporting partners on the site, and many have already). In fact a huge amount of interaction is between people who are never likely to meet; a Scot who cycles 100 miles before breakfast encouraging a mother-of-two who's working towards their her 5k, for example. It's been great to see how our users will give motivation freely, no matter what someone's level.

On the question of locale-specific Tribes, we certainly have a few of these, and users are welcome to create whatever Tribes they would find useful. We also have event-specific challenges for specific marathons, which are naturally localised. What we've found, though, is that our users seem to respond best to Tribes and Challenges that are globally relevant; things like the get fit without joining a gym Tribe (http://tribesports.com/tribes/get-fit-without-joining-a-gym), or the 5 minute plank Challenge (http://tribesports.com/challenges/hold-the-plank-pose-for-5-...).

You're absolutely right, though, more location-specific resources for users will be a key feature in future, and it's certainly something we'd like to develop further.

urbanautomaton··on Rate our startup: Tribesports - a social network for sportspeople
Good suggestion, thanks. :-)
urbanautomaton··on Rate our startup: Tribesports - a social network for sportspeople
Hi dadads, thanks for your comment.

Our userbase has expanded from an early base of friends and family, then through active seeding within carefully picked sports communities, and moved forwards with a great response from users themselves; our invitations system worked very well for us in the early stages, allowing users to send out exclusive invitations to their friends.

We've been really lucky to have such great early adopters - getting a power user or two early on is a huge motivation, gets you excellent feedback on what is and isn't working, and really makes the community feel alive, which is what keeps people coming back...

urbanautomaton··on Rate our startup: Tribesports - a social network for sportspeople
Ah right - we weren't aware of the ranking penalty. Previous "rate my startup" submissions were pretty universally non-linked ones, so we went with that, assuming direct links were specifically frowned upon for these posts for some reason. Live and learn...
urbanautomaton··on Rate our startup: Tribesports - a social network for sportspeople
They're auto-generated, and aren't enabled in "ask HN" OPs (as I understand it, at least). I guess this is to prevent people link-spamming...

(Edit - thanks for providing one. I'm another dev at Tribesports, by the way.)

← PreviousPage 2 of 2