A runtime in which developers can define, compile, and execute calculations against arbitrary data schemas
When Would You Use It?
You have a project whose problem domain centers around analysis: generating data by examining existing data. A survey system is a common example, as it collects values from users and performs different kinds of calculations on the answers:
- How many people filled out the entire survey?
- What is the average value of question 7?
- What percentage of the survey did Bob complete?
- Did Mary answer all required questions?
- What is the total of Joe's answers on page 3?
The results of asking each of these questions becomes a new data point available to future rounds of analysis. This allows a very fine-grained and iterative approach to describing relationships within a set of data.
Thanks to its declarative and compositional nature, Grasp works very well at the core of dynamic systems. Let's say your project involves letting users create their own surveys, complete with calculations and validation; your application, then, doesn't define a survey itself but instead serves as a middleman between its users and Grasp. This neatly sidesteps the problem of inventing a data definition and execution engine (as usually happens in this scenario) and instead allows you to focus on building features for your users.
Surveys are just one example of a form structure; Grasp targets any system which asks questions about data. See the Articles section below for more examples.
- Part 1: Overview
- Part 2: Variables
- Part 3: Calculations
- Part 4: Runtime
- Part 5: Executable
- Part 6: Validating Calculations
- Part 7: Compiling Calculations
- Part 8: Calculation Dependencies
- Part 9: Dependency Sorting
PM> Install-Package Grasp
Or from the online gallery:
Working with the Code
You will need the Code Contracts tooling to build the solution correctly. The method calls in the
System.Diagnostics.Contracts namespace are included in .NET 4; this simply allows Visual Studio to rewrite the assembly after it compiles:
Copyright © 2012 Bryan Watts