user-pic

mascip

  • About: Perl, Javascript (AngularJS), Coffeescript, Firebase
Subscribe to feed Recent Actions from mascip

  • Aristotle commented on "Functional core & Imperative shell" : OO design, and isolated tests without mocks
    Other than an unreliable external service, why mock anything up?

    Ovid, I linked you Gary Bernhardt’s Test Isolation Is About Avoiding Mocks in your own comments already – you really ought to read it. The (here deliberately over-summarised) punchline is that trying to test in isolation reveals invisible coupling. But really you ought to read the thing.

  • Samuel Kaufman commented on "Functional core & Imperative shell" : OO design, and isolated tests without mocks

    What external service is not unreliable? Any web service your code speaks to is by nature unreliable.
    Say for example your app sends emails. You write tests that send real emails. That's great, until the SMTP server goes offline. You've only tested against the live server when it was working, so you have no coverage for this.
    Of course, if it was your SMTP server you could turn it off and see how your code responds.
    If it isn't in your c…

  • Peter Martini commented on Prototypes and the call checker

    Zefram pointed me to http://search.cpan.org/dist/Debug-Show/lib/Debug/Show.pm, which is doing what I had in mind. Thanks!

  • J commented on The clearest way(s) to check if a List contains...

    I was just thinking on this the other day. To answer your Hash question: Like another commenter said hash lookup time is constant. It's can be a better choice when you want to search the array multiple times.

    When I was thinking about this I did some benchmarks. Hopefully I've done them right. I tested arrays of 100 elements searching for an integer that was in the middle of the array. I've pasted the results below.

    The way I interpret it is that you'd need to do at least 7 lookups for a hash lookup to be a better choice than grep, and around 25 lookups before it outperforms…

  • J commented on The clearest way(s) to check if a List contains...

    I forgot to mention that the reason why the lookup is slower on a single search in the first place is that I'm converting the array to a hash before doing the search. I'm using the "%hash = map { $_ => 1 } @array;" pattern you often see.

Subscribe to feed Responses to Comments from mascip

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.