Recently I have been toying around with fluent interfaces. Traditionally I preferred the classical Java Bean style of method naming (get/set) and definition but on several occasions (see past posts) fluent interfaces crept into JADE.
Today I added some potions to JADE that either grant positive or negative attribute modifiers for a certain amount of time. They are modeled by conditions which a being can be in. Each condition has certain effects and to put a being into a condition you have to create a so-called ConditionDefinition. And this - for attribute modifiers - now is done with a fluent interface. The original code (before refactoring temporary attribute modifications to the Being base class) looked like this:
public class AbstractAttributeBoostingPotion
extends AbstractPotion
{
private Attribute attribute;
...
protected void drinkImpl(Being being)
{
ConditionDefinition attributeModification
= attribute.modifier(status().based(+1, +3, +5))
.lasting(status().based("4d4", "8d6", "12d8")).actions();
being.inflict(attributeModification);
}
}
Oh, BTW… 18 potions also were added ![]()
8 responses so far ↓
1 Salajem // Nov 6, 2008 at 2:36 am
Cool! How are you doing with that Ph.D Work?
2 ty5479 // Nov 6, 2008 at 5:22 am
Looking good.
3 Sikor // Nov 6, 2008 at 7:24 am
It is very bad style!
For example (C# 3.5):
class SomeSettings {
public Color Color { get; set; }
public double Height { get; set; }
public double Weight { get; set; }
}
class Program {
static void Main (string [] args) {
SomeSettings settings = new SomeSettings { Color = Color.Black, Height = 10d, Weight = 20d };
}
}
4 kridma // Nov 6, 2008 at 7:24 am
Preved!
When, when, when?!
5 Epythic // Nov 22, 2008 at 7:40 pm
Could you please upload the latest javadoc?
I find it extremely interesting to read, but the one that’s online is horribly out of date (it’s from 2004)…
Thanks!
6 L // Dec 4, 2008 at 2:21 pm
Doh, no new Adom version,
Stop Developing JADE, work on ADOM. It is your greatest developing achievement. I regret that you did not finish it. Version 1.1.1 is not perfect. It need some improvements.
Work on Jade on your retirement, when you will have a lot of free time. Now, when you don’t even have time to post one message on blog you should not work on big thing like JADE.
7 Karl // Dec 5, 2008 at 12:33 pm
“Dear Thomas,
Since life is so short, and a man can achieve only a limited amount of thing in is short life span, I beg you to cure cancer, world hunger, and war (can you bitchslap all these hippies too ? pleaaase!)
When you’ll have done all these thing, you’ll be probably so old and senile that it’ll be time to work on ADOM.
After that, you may take a break, die, or work on Jade,
Thanks,
Sincerly,”
Here, fixed it for you, L. :p
8 Salajem // Dec 5, 2008 at 6:21 pm
So I’m not the only one who says that he will release the first version of JADE after his retirement XDDXDD
Think about it a little, L, if he does not have time to program JADE, I’m certain that he will not have time to program ADoM, Either.
You must log in to post a comment.