weblog.masukomi.org

mah-soo-koh-me

 

Do creatively chained methods constitute a DSL? June 22, 2007

Filed under: Uncategorized — masukomi @ 4:17 pm

Do creatively chained methods constitute a DSL?

I found a nice example (see below) of chained methods in
this
post about Using a DSL to create a fluent interface to test your domain
model
. But I have to wonder… Is this really a DSL? Especially when you
consider the excellent points in
What’s
a Ruby DSL and what isn’t
. This isn’t a rhetorical question, I’d really like
your input, as I implemented this style of programming in
Compensate and
was quite pleased with the results.


      public static Person CreateHennieLouwUsingDSL()
{
return PersonBuilder.StartRecording()
.CreatePerson(Title.Mr, “Hennie”, “Louw”, new DateTime (1971, 8, 7), Gender.Male)
.PrefersToSpeak(CorrespondenceLanguage.English)
.WithCitizenshipDetailsOf(EthnicGroup.White, “7108070108083″)
.WithMaritalStatusOf(MaritalStatus.Married)

.WithPrimaryJobOf(“Software Developer”)
.WorksAt(“Microsoft Ltd”, “Pinelands”)
.EarnsMonthlyIncomeOf(10000M)

.WithCellNumberOf(“+27″, “82″, “2824827″)
.WithHomeNumberOf(“+27″, “21″, “9814402″)
.WithPostalAddressOf(“6 Sinai Close”, “Cape Town”, “8000″)
.WithHomeEmailOf(“hennie.louw@gmail.com”)

.Finish();
}


 

Leave a Reply