Fluent.Calculations.DotNetGraph
                              
                            
                                1.1.0-aplha.59
                            
                        
                    dotnet add package Fluent.Calculations.DotNetGraph --version 1.1.0-aplha.59
NuGet\Install-Package Fluent.Calculations.DotNetGraph -Version 1.1.0-aplha.59
<PackageReference Include="Fluent.Calculations.DotNetGraph" Version="1.1.0-aplha.59" />
<PackageVersion Include="Fluent.Calculations.DotNetGraph" Version="1.1.0-aplha.59" />
<PackageReference Include="Fluent.Calculations.DotNetGraph" />
paket add Fluent.Calculations.DotNetGraph --version 1.1.0-aplha.59
#r "nuget: Fluent.Calculations.DotNetGraph, 1.1.0-aplha.59"
#:package Fluent.Calculations.DotNetGraph@1.1.0-aplha.59
#addin nuget:?package=Fluent.Calculations.DotNetGraph&version=1.1.0-aplha.59&prerelease
#tool nuget:?package=Fluent.Calculations.DotNetGraph&version=1.1.0-aplha.59&prerelease

Fluent Calculations
One of the more powerful ways to make a program readable is to break the calculations up into intermediate values that are held in variables with meaningful names. - Robert C. Martin, Clean Code, A Handbook of Agile Craftsmanship
<div align="justify"> By following this principle together wit Fluent Calculations library we gain an ability to write readable calculations as well as get insights at runtime. </div>
Motivation
<div align="justify"> <p> Having worked on many line of business and some finance applications authors have observed a common difficulty of understating and communicating non-trivial business logic or calculations. </p><p> Validating the correctness of financial calculations, like tax calculations for example, involves a lot of effort on analyst or tester side. For a developer pinpointing problems from just the final result is challenging, thus often we resort to manual debugging. </p><p> TDD falls short of communicating more complex test cases to business people as it relies on quite granular decomposition. Splitting up some algorithms is not always a good option too, due to loss of the original conciseness. Troubleshooting calculations happening in a production environment is impossible without deploying some manual logging that makes code noisy and less readable. </p> <p> This project attempts to provide a clean way to get an <b>"X-ray"</b> of calculations or business logic. </p> </div>
The Goal
Spend minutes of programming to save hours of debugging and testing.
Features
- Number (Decimal) and Condition (Boolean) datatype are supported,
 - Seamlessly use C# math and logic operators,
 - Build isolated calculation components,
 - Close to no boilerplate code,
 - Serialize calculation tree to JSON,
 - Generate DOT graph output of your calculations,
 - Render graph as an image.
 
Get Started
Fluent.Calculations can be installed using the Nuget package manager or the dotnet CLI.
dotnet add package Fluent.Calculations.Primitives
Documentation
Usage/Examples
Basic demo calculation:
public class Demo : EvaluationScope<Number>
{
    Number
        A = Number.Of(1),
        B = Number.Of(2),
        C = Number.Of(3);
    Number D => Evaluate(() => A + B);
    Number E => Evaluate(() => D * C);
    public override Number Return() => E;
}
Number result = new Demo().ToResult();
The result value can be :
- Serialized to JSON (example: fluent-calculation-demo.json),
 - Converted to DOT Language (example: fluent-calculations-demo.dot),
 - Rendered using DOT rendering programs and utilities.
 
<img src="../assets/example/fluent-calculations-demo.dot.png" alt="Demo calculation graph rendering" width="280" height="auto">
Challenges
- Explore ways to introduce concept of units (Meters, Kilograms, etc.).
 - Expand a list of supported operations and math functions.
 - Explore ways to optimize lambda expression compilation.
 - Explore a ways to reuse existing calculations and attempt to benefit from :
- Cache compiled expressions,
 - Cache evaluation results,
 - Partial execution depending on changed parameters.
 
 - Explore thread-safety aspects.
 
License
GNU General Public License v3.0
Authors
🚀 About The Team
We are bunch of .NET practitioners always looking for ways to make code great.
Give it a star ⭐
Loving it? Show your support by giving this project a star!
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
- 
                                                    
net8.0
- DotNetGraph (>= 3.0.0)
 - Fluent.Calculations.Primitives (>= 1.1.0-aplha.59)
 - QuikGraph.Graphviz (>= 2.5.0)
 
 
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Fluent.Calculations.DotNetGraph:
| Package | Downloads | 
|---|---|
| 
                                                        
                                                            Fluent.Calculations.Graphviz
                                                        
                                                         Package Description  | 
                                                    
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | 
|---|---|---|
| 1.1.0-aplha.59 | 133 | 3/24/2024 | 
| 1.1.0-aplha.58 | 88 | 3/24/2024 | 
| 1.1.0-aplha.57 | 81 | 3/24/2024 | 
| 1.1.0-aplha.56 | 93 | 3/24/2024 | 
| 1.1.0-aplha.55 | 85 | 3/23/2024 | 
| 1.1.0-aplha.54 | 83 | 3/23/2024 | 
| 1.1.0-aplha.53 | 82 | 3/23/2024 | 
| 1.1.0-aplha.52 | 83 | 3/21/2024 | 
| 1.1.0-aplha.51 | 88 | 2/24/2024 | 
| 1.1.0-aplha.50 | 89 | 2/22/2024 | 
| 1.1.0-aplha.49 | 140 | 1/11/2024 | 
| 1.1.0-aplha.48 | 129 | 12/30/2023 | 
| 1.1.0-aplha.47 | 98 | 12/30/2023 | 
| 1.1.0-aplha.46 | 102 | 12/30/2023 | 
| 1.1.0-aplha.45 | 96 | 12/30/2023 | 
| 1.1.0-aplha.44 | 96 | 12/30/2023 | 
| 1.1.0-aplha.43 | 101 | 12/30/2023 | 
| 1.1.0-aplha.42 | 113 | 12/30/2023 | 
| 1.1.0-aplha.41 | 92 | 12/30/2023 | 
| 1.1.0-aplha.40 | 103 | 12/28/2023 | 
| 1.1.0-aplha.39 | 106 | 12/21/2023 | 
| 1.1.0-aplha.38 | 107 | 12/18/2023 | 
| 1.1.0-aplha.37 | 100 | 12/17/2023 | 
| 1.1.0-aplha.36 | 106 | 12/5/2023 | 
| 1.1.0-aplha.35 | 109 | 11/27/2023 | 
| 1.1.0-aplha.34 | 100 | 11/22/2023 | 
| 1.1.0-aplha.33 | 97 | 11/19/2023 | 
| 1.1.0-aplha.32 | 102 | 11/16/2023 | 
| 1.1.0-aplha.31 | 101 | 11/15/2023 | 
| 1.1.0-aplha.30 | 97 | 11/13/2023 | 
| 1.1.0-aplha.29 | 87 | 11/11/2023 | 
| 1.1.0-aplha.28 | 92 | 11/10/2023 | 
| 1.1.0-aplha.27 | 91 | 11/10/2023 | 
| 1.1.0-aplha.26 | 81 | 11/10/2023 | 
| 1.1.0-aplha.25 | 104 | 11/9/2023 | 
| 1.1.0-aplha.24 | 101 | 11/9/2023 | 
| 1.1.0-aplha.23 | 94 | 11/9/2023 | 
| 1.1.0-aplha.22 | 94 | 11/9/2023 | 
| 1.1.0-aplha.21 | 100 | 11/9/2023 | 
| 1.1.0-aplha.20 | 98 | 11/9/2023 | 
| 1.1.0-aplha.19 | 92 | 11/9/2023 | 
| 1.1.0-aplha.18 | 95 | 11/9/2023 | 
| 1.1.0-aplha.17 | 98 | 11/9/2023 | 
| 1.1.0-aplha.16 | 93 | 11/8/2023 | 
| 1.1.0-aplha.15 | 99 | 11/8/2023 | 
| 1.1.0-aplha.14 | 96 | 11/8/2023 | 
| 1.1.0-aplha.13 | 109 | 11/3/2023 | 
| 1.1.0-aplha.12 | 106 | 10/31/2023 | 
| 1.1.0-aplha.11 | 102 | 10/30/2023 | 
| 1.1.0-aplha.10 | 121 | 10/25/2023 | 
| 1.1.0-aplha.9 | 105 | 10/23/2023 | 
| 1.1.0-aplha.8 | 105 | 10/19/2023 | 
| 1.1.0-aplha.7 | 112 | 10/16/2023 | 
| 1.1.0-aplha.6 | 118 | 10/9/2023 | 
| 1.1.0-aplha.5 | 114 | 10/8/2023 | 
| 1.1.0-aplha.4 | 111 | 10/8/2023 | 
| 1.1.0-aplha.3 | 108 | 9/24/2023 | 
| 1.1.0-aplha.2 | 106 | 9/22/2023 | 
| 1.1.0-aplha.1 | 114 | 9/19/2023 | 
| 1.1.0-alpha | 125 | 9/12/2023 | 
| 1.0.19-alpha.1 | 119 | 9/12/2023 | 
| 1.0.19-alpha | 122 | 9/12/2023 | 
| 1.0.18-alpha.4 | 119 | 9/11/2023 | 
| 1.0.18-alpha.3 | 115 | 9/11/2023 | 
| 1.0.18-alpha.2 | 139 | 9/11/2023 | 
| 1.0.17-alpha | 124 | 9/10/2023 | 
| 1.0.16-alpha | 144 | 9/10/2023 | 
| 0.0.0-alpha.0.31 | 131 | 9/11/2023 | 
| 0.0.0-alpha.0 | 126 | 9/11/2023 |