Marin Fowler puts a name to a particular type of programming style/API/interface: FluentInterface. It can best be summarized as:
private void makeFluent(Customer customer) { customer.newOrder() .with(6, "TAL") .with(5, "HPK").skippable() .with(3, "LGV") .priorityRush(); }
In this case, each of methods (with, skippable, priorityRush) return an object which can be in turn manipulated.
This is a clever solution to making blocks of Java code look as clean as possible. While this style seems to cry out for pretty specific circumstances, it's worth having in mind.
No comments:
Post a Comment