Tuesday, February 08, 2011

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:

...

SNAGHTML8e597856..."

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

NOTE: Anonymous Commenting has been turned off for a while... The comment spammers are just killing me...

ALL comments are moderated. I will review every comment before it will appear on the blog.

Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...

I reserve, and will use, the right to not approve ANY comment for ANY reason. I will not usually, but if it's off topic, spam (or even close to spam-like), inflammatory, mean, etc, etc, well... then...

Please see my comment policy for more information if you are interested.

Thanks,
Greg

PS. I am proactively moderating comments. Your comment WILL NOT APPEAR UNTIL I approve it. This may take some hours...