« May 2011 | Main | July 2011 »

June 11, 2011

Four Fish

Four Fish: The Future of the Last Wild FoodFour Fish: The Future of the Last Wild Food by Paul Greenberg

My rating: 3 of 5 stars


An exploration of four common fish driven by a personal narrative of fishing for them. Along the way current trends in aquaculture, genetic research, alternative fish types, and legislation are explained. Human greed and fisherman psychology seem to a driving force behind how we got to where we are today with fishing and it seems that without drastic measures nothing will change. The author doesn't advocate ceasing fishing as some other authors have. Instead the author recommends starting over thinking about what we eat using Francis Galton's criteria: hardy, endowed with an inborn liking for man, comfort-loving, able to breed freely, and needful of only a minimal amount of tending. Making strong international policy changes to: profoundly reduce fishing, create large no-catch areas, protect unmanageable species, and protect the bottom of the food chain. With those in mind he advocates creating a fishing industry build around: efficiency, nondestructive to wild systems, limited in number, adaptable, and functional in a polyculture.



View all my reviews

Tags: books food

June 2, 2011

Capture an Argument Matcher

More than once I've found myself writing unit test code for a class that internally constructs an object which is then passed along to another method. A common pattern would be to introduce a factory for this internally created object, but at times this feels too heavy weight. I'd still like to make a few assertions about the object but this can get tricky when using lots of mock objects. Enter a little utility class called CaptureArgument. It is a type safe matcher that, wait for it, captures the argument it matched which allows you to inspect it. You can grab a copy of the class at GitHub. Below is a sample usage:

final MBeanServer mBeanServer = context.mock(MBeanServer.class);
final Object objectToRegister = new Object();
final CaptureArgument<ObjectName> captureArgument = new CaptureArgument<ObjectName>();
context.checking(new Expectations() {{
        oneOf(mBeanServer).registerMBean(with(same(objectToRegister)), with(captureArgument));
    }});
unitUnderTest.doSomething(objectToRegister);
assertEquals("BeanDomain", captureArgument.getArgument().getDomain());

Tags: java junit

June 1, 2011

Seven Languages in Seven Weeks

Seven Languages in Seven WeeksSeven Languages in Seven Weeks by Bruce A. Tate

My rating: 3 of 5 stars


This book offers an exploration of various programming paradigms (object oriented, prototype, constraint-logic, and functional), concurrency models (actors, futures, and transactional memory), and programming constructs (list compression, monads, and matching). None of the topics are covered in great detail but for those curious what Ruby, Io, Prolog, Scala, Erlang, Clojure, and Haskell are all about, this book does a reasonable job of introducing and demonstrating each language. The writing is uneven between the chapters and some concepts (like monads and monitors) could use much better code examples. As the introduction emphasizes, to really get the most put of the book, you will want to work through the exercises at the end of each day, as that is the best way to get a feel for each language. Be warned there aren't answers to these problems, despite what the introduction alludes to.



View all my reviews

Tags: books