John Slaby discusses the reasons why he prefers fluent APIs and examine, through examples, the many different ways that Fluent APIs can be used to help produce better solutions than external DSLs.
John Slaby is an Engineering Fellow at Raytheon with over 25 years experience in software and systems engineering. At Raytheon, he has been a Software Architect on numerous programs and was the Principal Investigator for research projects on model-driven software development and domain-specific modeling languages. He is currently the engineering lead on an applied research project.
Code Generation conference is the leading event on the practical applications of Model-Driven Software Development (MDSD). It offers a high quality learning experience through discussions, debates, a diverse range of practical tutorials and workshops. Now in its 7th year, it is known for providing a high-value learning experience and attracts industry-recognised experts to share their experiences.
In xTend, you can write:
this.gameState = GameStateFactory.DefaultGameState(this.game) => [
The with operator accepts a lambda expression (equivalent to Action<GameState>), and returns the object it was applied on.
The object instance is an implied context in the lambda body, and you can invoke any methods on it. You can also use the "it" keyword to refer to it explicitly.
This way, you don't need to modify all methods to return the object instance.
Another advantage is that you can include arbitrary code in the lambda body.
I wish C# had that feature as well.
Why not use lemonade instead of gas in the car then?
However, I like the speaker's comment: "... have become pragamtic enough to take small victories..."