Wednesday, March 02, 2011

Fluent API Navigation–What’s the member returning?

Getting up and down an object map isn’t easy, especially when you don’t understand the API.  Some APIs allow “chaining” where I can write something like Coffee.MakeCup().CupSize(‘Large’). 

What this example implies is that each child member/method call returns itself or the base.  Determining if something is returning itself or the base is a pretty big distinction / way of thinking.

This can be applied to people: does this guy really believe what he’s saying or is he just a talking head?  People that “return the base” are not representing themselves.  People who return themselves are real and authentic. 

I’m not saying that one is better than the other but there are situations and needs for both.  This is a fundamental design decision.

No comments: