Expression Builder, DSL, Fluent Interfaces and C#, RPG (as in role playing game) Style
Primary Objects - Fluent Interfaces in C# .NET with Expression Builder Method Chaining and RPG Games
"...
In this tutorial, we'll create a simple RPG role-playing game. We'll create a character, assign his attribute statistics including strength, agility, intelligence, and class. We'll then put him to battle against an endless barrage of enemies and see how long he lasts! We'll focus on an internal domain specific language for our design. In particular, we'll implement a fluent interface design, using the popular Expression Builder pattern with method chaining and progressive interfaces. The Expression Builder pattern is a popular design used in internal domain specific languages and it will allow us to create a fluent implementation of the Character class, leaving an expressive implementation of heroes and enemies in our programming logic.
A Hero Without a Cause
Since we'll be creating a simple role-playing RPG game, we'll need to first implement a basic character class. Before we get to the details of the class, assume it will contain various attributes for name, class, age, hit points, strength, agility, intelligence, gold, and possibly more. Instantiating the Character in a traditional fashion might be done using the following code:...
Who didn't learning programming by coding some kind of D&D/RPG game thing? (okay, anyone learning in the last decade or two... um... shut up? lol :P )
Anyway...
Fluent is "in" right now and how better to learn it than via RPG examples... ;)
No comments:
Post a Comment