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 Rob Thornton on Sep 20, 2007
Anders Noras introduced the Quaere library, billed as LINQ for Java, last week at JavaZone. Quaere is a DSL providing query functionality against any structure implementing Iterable or its Queryable interface.
Noras lists the features of Quaere:
An example of retrieving a list of product name’s from a list of products is:
Listproducts = Arrays.asList(Product.getAllProducts());
IterableproductNames =
from("p").in(products).
select("p.getProductName()");
Quaere currently has only one implementation (for objects), but a partial implementation is in place for Hibernate. The Hibernate implementation (and others with good criteria APIs) should progress quickly, Anders notes, as the demo of Hibernate only took a few hours.
Several people have noted that joSQL is a similar API. Anders himself notes the similarities but points out some key differences including:
Lastly, Noras has made an attempt to answer common questions about Quaere and has created a project for it on Codehaus.
18 agile and lean practices for effective software development governance
NOSQL, The Web And The Enterprise
A Guide to Branching and Merging Patterns
SCM best practices for multiple processes, releases & distributed teams
The Codehaus link at the end of the article is broken. This is the correct link.
Given the use of strings in the select and presumably where clauses, is this truly type safe? Won't type safety require closures?
Fixed the link. Thanks for the catch!
First of all a big thank-you is due for writing about my humble project. Parts of the code example provided seem to have gotten "lost in HTML". Although the code in the example will compile and run, it should make use of generics to increase type safety.
List<Product> products = Arrays.asList(Product.getAllProducts());
Iterable<String> productNames =
from("p").in(products).
select("p.getProductName()");
Cheers,
Anders
Using Strings does not provide type safety. With current Java it is still possible:Test t = db.alias(Test.class);
db.from(t).where(t.id == 1).select(t.id, t.name);
The problem here is how to convert 't.id == 1' and 't.id, t.name' into a expression tree (and then possibly SQL). Solution: get the calling class and line number. That's easy:StackTraceElement e = new Error().getStackTrace()[0];
Class callingClass = e.getClass();
String method = e.getMethodName();
int line = e.getLineNumber();
Now, get the byte code of the class, decompile this method (harder but possible), and extract the expression tree. It can be done.
There are a few restrictions: 1) Requires debug info in the calling class. 2) Only one query per line of code. This can be solved: count how many times the method is called.
Maybe I should add this feature to my database (www.h2database.com)
Ehm... one more problem: where(t.id == x)
But this can be solved as well: Require that each parameter is listed:
Query where(boolean condition, Object ... parameters)
The the query becomes:
where(t.id == x, x)
The only problem now: You can't detect unknown parameters at regular compile time. This would require an additional compile step (_after_ the regular compilation). Any more problems?
A solution without decompilation:class Test {
Integer id;
String name;
}
Test t = alias(Test.class);
from(t).where(equal(t.id, x)).select(t.id, t.name);
The method alias() would have to initialize the Test instance (assign a new object to each field). The methods equal() and select() could then check at runtime if such an object is passed and thus can reconstruct the expression tree. Disadvantages: int/long/double are not supported (except when using Integer.MIN_VALUE + 10, 11,..., but that would be a hack). A method is required for each operation (=, >, <, +,...).
If you drop the POJO requirement, you could even get more type savety:class Person {
static final Person TABLE = Db.alias(Person.class);
public DbInt id = DbInt.pk();
public DbString name;
}
...
Person p = Person.TABLE;
Person found = db.from(p).where(p.id.eq(10)).get();
for (Person a : db.from(p).
order(p.id.asc(), p.name.desc()).
select()) {
System.out.println(a.name.value);
}
Person one = db.from(p).
where(p.id.eq(x).and(p.name.eq(name))).
get();
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.
8 comments
Watch Thread Reply