Your SlideShare is downloading. ×
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Fluent Validation Framework - A DSL for validations using fluent interfaces
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Fluent Validation Framework - A DSL for validations using fluent interfaces

2,736

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,736
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
25
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Overall
presenta3on
 Introduc3on
to
Domain
Specific
Languages
and
 its
techniques.
As
well
as
showing
Fluent
 Valida3on
Framework
concep3on
process.

 www.devoxx.com

  • 2. Domain
Specific
Language
(DSL)
is
a
 programming
language
dedicated
to
 solve
problems
of
an
specific
domain
 www.devoxx.com

  • 3. which
can
be
technical

  SQL
  HQL
  CSS
 www.devoxx.com

  • 4. or
business
related.
  Banking
  Manufacturing
  Logis3cs
 www.devoxx.com

  • 5. A
DSL
can
be
internal
or
external.
 www.devoxx.com

  • 6. External
DSLs
are
self‐contained
 www.devoxx.com

  • 7. while
internal
DSLs
remain
on
top
of
 other
programming
languages.
 www.devoxx.com

  • 8. In
other
words,
internal
DSLs
are
APIs.
 www.devoxx.com
 That's why they're also known as Fluent Interfaces!

  • 9. DSLs
allow
you
to
express
domains
clearly.
 www.devoxx.com

  • 10. For
example,
while
a
business
analyst
of
 a
banking
domain
would
say
 Transfer 5.000,00 from Client A's cash account to Client B's savings account.
 www.devoxx.com

  • 11. A
common
JAVA
implementa3on
could
be
 bankService.transfer(5000.00, clientA.getCashAccount(), clientB.getSavingsAccount());
 www.devoxx.com

  • 12. An
external
DSL
could
express
the
same
as
 transfer 5000 from clientA.cashAccount to clientB.savingsAccount
 www.devoxx.com

  • 13. And
an
internal
DSL
in
JAVA
could
look
like
 bankService.execute( new Transfer() .of(5000) .from(clientA.cashAccount()) .to(clientB.savingsAccount()));
 www.devoxx.com

  • 14. It’s
not
about
one
single
method
 public
Transfer
of(double
value);
 www.devoxx.com

  • 15. but
an
en3re
meaningful
opera3on.
 new Transfer() .of(5000) .from(clientA.cashAccount()) .to(clientB.savingsAccount()) www.devoxx.com

  • 16. Some
techniques
to
define
internal
DSLs
 www.devoxx.com

  • 17. Method
Chaining
 new Transfer() .of(5000) .from(clientA.cashAccount()) .to(clientB.savingsAccount()) www.devoxx.com

  • 18. Nested
Func3on
 bankService.transfer(5000, from(clientA.cashAccount()), to(clientB.savingsAcount())); www.devoxx.com

  • 19. Object
Scoping
 bankService.execute( new Transfer(){{ of(5000); from(clientA.cashAccount()); to(clientB.savingsAccount()); }}); www.devoxx.com

  • 20. Fluent
Valida3on
Framework
is
a
lab
 project
applying
Fluent
Interfaces
to
the
 domain
of
code
valida3on.
 www.devoxx.com

  • 21. Main
idea
was
changing
valida3ons
like
 if(arg0 == null) throw new IllegalArgumentException(); www.devoxx.com

  • 22. to
something
like
 ensure(arg0).isNotNull(); www.devoxx.com

  • 23. How
to
change
excep3on
message?
 ensure(arg0).isNotNull().otherwise("arg0 cannot be null"); //doesn't work www.devoxx.com

  • 24. Trigger
method
at
the
end
of
the
expression
 ensure(arg0).isNotNull().now(); ensure(arg0).isNotNull() .otherwise() .throwThis( new IllegalStateException()) .now(); //not cool! www.devoxx.com

  • 25. Another
op3on
was
crea3ng
two
entry
points
 ensure(arg0).isNotNull(); analyse(arg0).and().throwThis(new IllegalStateException()).ifNull(); www.devoxx.com

  • 26. Mixing
method
chaining
with
nested
func3ons
 ensure(myObject).is(inValidState()); analyse(systemReport).and(notifyByEmail()).ifIsNot(operatingWell()); www.devoxx.com
 the
solu3on
became
extensible!


  • 27. Today
we
saw
  DSLs
are
cool!
  External
DSLs
are
hard
to
implement
  Fluent
Interfaces
and
Internal
DSLs
are
the
same
thing
  Fluent
Interfaces
work
great
for
extensively
used
APIs
 www.devoxx.com

  • 28. That’s
all
folks!
  project
hXp://fluval.sourceforge.net
  blog
hXp://blog.danielgazineu.com
  email/gtalk
danielgazineu@gmail.com
  twiXer
@danielgazineu
 www.devoxx.com


×