10 tips on how to prevent business value risk
One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.
The content has been bookmarked!
There was an error bookmarking this content! Please retry.
Posted by Werner Schuster on Feb 04, 2008
tap method has been around for some time - but it has now been added to the standard Ruby library in Ruby 1.9. MenTaLguY, who blogged about the idea behind tap shows the simple code:class Object
def tap
yield self
self
end
end
tap method is defined in Object, making it available for every object in Ruby by default. The method takes a Block as argument, which it calls with self as argument - then the object is returned. tap method seems like a complicated way of doing something with an object. The real benefit of this becomes clear when the object of interest is passed from one method to another without ever being assigned to a variable. This is common whenever methods are chained, particularly if the chain is long. xs = blah.sort.grep( /foo/ )
p xs
# do whatever we had been doing with the original expression
xs.map { |x| x.blah }
tap:blah.sort.grep( /foo/ ).tap { |xs| p xs }.map { |x| x.blah }
tap is useful: without it, it's necessary to assign the object of interest to a local variable to use it - with tap it's possible to insert the Block that inspects the object right where the handover between the chained methods happens. This gets particularly useful with APIs that expose so called Fluent Interfaces - i.e. APIs that encourage method chaining. Here a Java example from Martin Fowler's website:
customer.newOrder()
.with(6, "TAL")
.with(5, "HPK").skippable()
.with(3, "LGV")
.priorityRush();
tap allows to look at the object at an arbitrary stage (i.e. between every call) by simply inserting a tap block. This is also useful with debugging tools, which often don't support looking at anonymous return values of methods. tap is normally about causing some kind of side effect without changing the object (the Block's return value is ignored). However, it is of course possible to modify the object as long as it's mutable. returning method . tap method is not restricted to Ruby 1.9 - Ruby's Open Classes allow to do this on non-1.9 Ruby versions too.
A Guide to Branching and Merging Patterns
Monitor your Production Java App - includes JMX! Low Overhead - Free download
SCM best practices for multiple processes, releases & distributed teams
Agile Development: A Manager's Roadmap for Success
Agile Maturity Model Applied to Building and Releasing Software
One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.
InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.
Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.
John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.
Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.
Are there repeated patterns of failure on Enterprise Agile Enablement efforts? Sanjiv and Arlen discuss Seven Deadly Sins to avoid when adopting Agile in an enterprise.
Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?
Sean Cribbs explains what Map-Reduce and Riak are, why and how to use Map-Reduce with Riak, and how to convert SQL queries into their Map-Reduce equivalents.
No comments
Watch Thread Reply