specification 0.0.2

  • README.md
  • Installing
  • Versions
  • 30

#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

Use this package as a library

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:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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';
  
Version Uploaded Documentation Archive
0.0.2 Jul 1, 2013 Go to the documentation of specification 0.0.2 Download specification 0.0.2 archive
0.0.1 Apr 26, 2013 Go to the documentation of specification 0.0.1 Download specification 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
30
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:specification/specification.dart.

Health suggestions

Fix lib/src/composite.dart. (-1.49 points)

Analysis of lib/src/composite.dart reported 3 hints:

line 10 col 11: Always override hashCode if overriding ==.

line 27 col 17: Always override hashCode if overriding ==.

line 47 col 17: Always override hashCode if overriding ==.

Format lib/src/core.dart.

Run dartfmt to format lib/src/core.dart.

Format lib/src/expression.dart.

Run dartfmt to format lib/src/expression.dart.

Format lib/src/operators.dart.

Run dartfmt to format lib/src/operators.dart.

Format lib/src/predicate.dart.

Run dartfmt to format lib/src/predicate.dart.

Maintenance issues and suggestions

Package is too old. (-100 points)

The package was released more than two years ago.

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Maintain an example.

None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use specification.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=0.4.7+1
Dev dependencies
unittest any