specification 0.0.2

#Specification.dart

##Dart implementation of the Specification pattern in Domain Driven Design.

Build Status

What is the specificaiton pattern?

the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic.

"Specification pattern." Wikipedia: The Free Encyclopedia. Wikimedia Foundation, Inc. 15 April 2013. Web. 27 April 2013.

Examples

import 'package:specification/specification.dart' as spec;

main () {
  var spec1 = spec.expr((value) => value.length > 2);
  var spec2 = spec.expr((String str) => str.startsWith("abc"));
  
  var conjunction = spec1 & spec2;
  print(conjunction.isSatisfiedBy("a"));      // false
  print(conjunction.isSatisfiedBy("abb"));    // false
  print(conjunction.isSatisfiedBy("abcde"));  // true
  
  var disjuction = spec1 | spec2;
  print(disjuction.isSatisfiedBy("a"));       // false
  print(disjuction.isSatisfiedBy("abb"));     // true
  print(disjuction.isSatisfiedBy("abcde"));   // true
  
  var negation = ~spec1;
  print(negation.isSatisfiedBy("a"));         // true
  print(negation.isSatisfiedBy("abb"));       // false
  print(negation.isSatisfiedBy("abcde""));     // false
  
  var exclusiveDisjunction = spec1 ^ spec2;
  print(exclusiveDisjunction.isSatisfiedBy("a"));     // false
  print(exclusiveDisjunction.isSatisfiedBy("abb"));   // true
  print(exclusiveDisjunction.isSatisfiedBy("abcde")); // false
}

Licence

see LICENSE

Author

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  specification: "^0.0.2"

2. Install it

You can install packages from the command line:

$ pub get

Alternatively, your editor might support 'pub get'. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:specification/specification.dart';

About

Dart implementation of the Specification pattern in Domain Driven Design.

Author

Email tomochikahara@gmail.com Tomochika Hara

Homepage

github.com/tomochikahara/specification.dart

Documentation

www.dartdocs.org/documentation/specification/0.0.2/

Source code (hyperlinked)

www.crossdart.info/p/specification/0.0.2/

Uploader

tomochikahara@gmail.com

Published

Jul 1, 2013

Share